How to search for a string in complex fields in MongoDB?

时间:2017-06-09 12:57:32

标签: mongodb mongoose mongodb-query

I want to search for a string in complex fields.

Let's say entity object is

{
    _id: "12312",
    name: {
        "en": "English name",
        "br": "brasilian name
}

And when I make a search, I want to search in all fields of name.

So

db.getCollection('entities').find({"name": /sil/i});
db.getCollection('entities').find({"name": /gl/i});

should give me this document. How can I do that?

0 个答案:

没有答案