Checking if a field contains a string

You can do it with the following code.

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

Leave a Comment