mongodb if clause check string contains code example
Example 1: contains mongo-query string
db.users.findOne({"username" : {$regex : ".*son.*"}});
Example 2: mongodb check if substring in string
#all documents whose description field contains anywhere
#in the text the "beach" sub string
query = db.collection.find({
"description" : {"$regex" : ".*beach.*"}
})