According to the keywords, fuzzy query is carried out on the fields of the object array.

  mongodb, question

For example, the collection has such a field,

contacts:{
 [
 {
 address: "address1",
 Name: "Zhang San"
 },
 {
 address: "address2",
 Name: "Li si"
 },
 .....
 ]
 }

So how should I search for documents containing contacts with Zhang’s surname through “Zhang”?

ThroughFind ({'contacts.name': {$ regex:' sheets'}}})Get