Abhijeet Abhijeet - 3 months ago 8x
Node.js Question

Find all the documents having * in them in MongoDB

Can someone please help me with the regex for * in MongoDB.
I want to fetch all the documents having '*' in them.

like that regex (db.collection.find{value: new Regex('*')}) should return all such documents



You're close; you just need to add a backslash to escape the * in your regex so it won't be treated as a special character.

In the shell:

db.collection.find({value: /\*/})