Checking if a field contains a string
Asked 07 September, 2021
Viewed 1.9K times
  • 60
Votes

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?

14 Answer