Quantcast
Channel: How to query MongoDB with "like" - Stack Overflow
Browsing all 48 articles
Browse latest View live
↧

Answer by prayagupd for How to query MongoDB with "like"?

Like Query would be as shown below db.movies.find({title: /.*Twelve Monkeys.*/}).sort({regularizedCorRelation : 1}).limit(10); for scala ReactiveMongo api, val query = BSONDocument("title" ->...

View Article


Answer by Vaibhav for How to query MongoDB with "like"?

If you are using Spring-Data Mongodb You can do this in this way: String tagName = "m"; Query query = new Query(); query.limit(10); query.addCriteria(Criteria.where("tagName").regex(tagName));

View Article


Answer by The6thSense for How to query MongoDB with "like"?

Already u got the answers but to match regex with case insensitivity You could use the following query db.users.find ({ "name" : /m/i } ).pretty() The i in the /m/i indicates case insensitivity and...

View Article

Answer by Dap for How to query MongoDB with "like"?

For PHP mongo Like. I had several issues with php mongo like. i found that concatenating the regex params helps in some situations PHP mongo find field starts with. I figured I would post on here to...

View Article

Answer by cmarrero01 for How to query MongoDB with "like"?

You can use the new feature of 2.6 mongodb: db.foo.insert({desc: "This is a string with text"}); db.foo.insert({desc:"This is a another string with Text"}); db.foo.ensureIndex({"desc":"text"});...

View Article


Answer by Johnathan Douglas for How to query MongoDB with "like"?

db.users.insert({name: 'paulo'}) db.users.insert({name: 'patric'}) db.users.insert({name: 'pedro'}) db.users.find({name: /a/}) //like '%a%' out: paulo, patric db.users.find({name: /^pa/}) //like 'pa%'...

View Article

Answer by MADHAIYAN M for How to query MongoDB with "like"?

In SQL, the ‘like’ query is looks like this : select * from users where name like '%m%' In MongoDB console, it looks like this : db.users.find({"name": /m/}) // Not JSON formatted...

View Article

Answer by user2312578 for How to query MongoDB with "like"?

In Go and the mgo driver: Collection.Find(bson.M{"name": bson.RegEx{"m", ""}}).All(&result) where result is the struct instance of the sought after type

View Article


Answer by Eddy for How to query MongoDB with "like"?

If using node.js, it says that you can write this: db.collection.find( { field: /acme.*corp/i } ); //or db.collection.find( { field: { $regex: 'acme.*corp', $options: 'i' } } ); Also, you can write...

View Article


Answer by brenoriba for How to query MongoDB with "like"?

You can use where statement to build any JS script: db.myCollection.find( { $where: "this.name.toLowerCase().indexOf('m') >= 0" } ); Reference: http://docs.mongodb.org/manual/reference/operator/where/

View Article

Answer by Afshin Mehrabani for How to query MongoDB with "like"?

In PyMongo using Python Mongoose using Node.js Jongo, using Java mgo, using Go you can do: db.users.find({'name': {'$regex': 'sometext'}})

View Article

Answer by leon for How to query MongoDB with "like"?

In PHP, you could use following code: $collection->find(array('name'=> array('$regex' => 'm'));

View Article

Answer by Kyle H for How to query MongoDB with "like"?

That would have to be: db.users.find({"name": /.*m.*/}) or, similar: db.users.find({"name": /m/}) You're looking for something that contains "m" somewhere (SQL's '%' operator is equivalent to Regexp's...

View Article


Answer by Joshua Partogi for How to query MongoDB with "like"?

You would use regex for that in mongo. e.g: db.users.find({"name": /^m/})

View Article

How to query MongoDB with "like"?

I want to query something with SQL's like query: SELECT * FROM users WHERE name LIKE '%m%' How to do I achieve the same in MongoDB? I can't find an operator for like in the documentation.

View Article


Answer by Lazaro Fernandes Lima Suleiman for How to query MongoDB with "like"?

If you have a string variable, you must convert it to a regex, so MongoDb will use a like statement on it. const name = req.query.title; //Johndb.users.find({ "name": new Regex(name) });Is the same...

View Article

Answer by KayV for How to query MongoDB with "like"?

Here is the command which uses starts with paradigmdb.customer.find({"customer_name" : { $regex : /^startswith/ }})

View Article


Answer by Ezequias Dinella for How to query MongoDB with "like"?

You can query with a regular expression:db.users.find({"name": /m/});If the string is coming from the user, maybe you want to escape the string before using it. This will prevent literal chars from the...

View Article

Answer by ajay_fuel_stock_lamp_stack for How to query MongoDB with "like"?

There are various ways to accomplish this.simplest-onedb.users.find({"name": /m/}){ <field>: { $regex: /pattern/, $options: '<options>' } }{ <field>: { $regex: 'pattern', $options:...

View Article

Answer by waseem khan for How to query MongoDB with "like"?

One way to find the result as with equivalent to like querydb.collection.find({name:{'$regex' : 'string', '$options' : 'i'}}) Where i use for cases insensitive fetch dataAnother way by which we can get...

View Article
Browsing all 48 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>