How to extract documents whose values ​​end with a specific caharacter in mongoDB

I inserted the documents into a specific database in mongoDB. eg

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

now I want to extract documents whose name ends with an i .

+5
source share
1 answer

In Javascript shell use $ regex

db.employee.find({name: {$regex: "i$"}})
+10
source

All Articles