Search for similarity in mongo

1

I need to do a find on my mongo by similarity example

[
{
    "nome" : "Erick",
    "codigo" : 1,
    "periodos" : 10
},
{
    "nome" : "Erica",
    "codigo" : 1,
    "periodos" : 10
},
{
    "nome" : "Arthur",
    "codigo" : 2,
    "periodos" : 5
}
]

In my find then I will receive 'eric'

cursos.find({
nome: "eric"
}

I want you to return the two elements that contain these String, that is the Erick and Erica data

    
asked by anonymous 09.11.2017 / 01:04

1 answer

4

You can use regex :

cursos.find({nome: /^Eric/})

    
09.11.2017 / 01:12