I’m looking for an operator, which allows me to check, if the value of a field contains a certain string.

Something like:

db.users.findOne({$contains:{"username":"son"}})

Is that possible?

15 s
15

You can do it with the following code.

db.users.findOne({"username" : {$regex : "son"}});

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *