In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Case study of mgo specified string length to find data? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!
The content of this article is about the mgo specified string length to find data method introduction (code), there is a certain reference value, friends in need can refer to, hope to help you.
Work occasionally according to the length of the string field to filter some data, this time may use regular expressions, you can also use mongodb $where, regular expressions in different languages, the correct way to write different, here to record.
If you look for data with a comment field string length greater than 10, the mongodb command line is written as follows:
Where is written as follows:
Find ({"comment": {"$exists": true}, "$where": "this.comment.length > 10"})
How to write a regular expression:
Find ({"comment": {"$regex": / ^. {10,} $/}})
It is written as follows in go language:
Where is written as follows:
Collection.Find (bson.M {"comment": bson.M {"$exists": true}, "$where": "this.comment.length > 10"})
How to write a regular expression:
Collection.Find (bson.M {"comment": bson.M {"$exists": true, "$regex": bson.RegEx {`^. {10,} $`, ""})
Other conditions are regular:
^. {n ·m} $n
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.