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

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

  •  16-03-2022
  •  | 
  •  

Pergunta

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'.

Foi útil?

Solução

In Javascript shell, use $regex operator

db.employee.find({name: {$regex: "i$"}})
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top