How to retrieve the documents whose values ending with a particular character in mongoDB

StackOverflow https://stackoverflow.com/questions/15127791

  •  16-03-2022
  •  | 
  •  

質問

I inserted the documents into a particular database in mongoDB. for example

 db.employee.insert({name:"nithin",age:22})
 db.employee.insert({name:"sreedevi",age:32})

now i wnat to retrive the documents whose name ending with character 'i'.

役に立ちましたか?

解決

In Javascript shell, use $regex operator

db.employee.find({name: {$regex: "i$"}})
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top