[Root @ sunrise16 bin] #./mongo
MongoDB shell version: 2.0.0
Insert a document with array elements
Queries documents with a specified value in an array element.
> Db. food. find ({"fruit": {"$ all": ["banana"]})
Queries documents that match the specified array. Make sure that the number and order must be exactly the same; otherwise, the number and order cannot be found.
> Db. food. find ({"fruit": ["banana"]})
Queries documents whose array elements contain multiple specified values, all of which are irrelevant to the order.
> Db. food. find ({"fruit": {"$ all": ["banana", "apple", "peach"]})
Query a document that contains one of multiple values
> Db. food. find ({"fruit": ["banna", "cherry"]})
Queries an array of the specified length. However, you cannot query arrays with a specified length range.
> Db. food. find ({"fruit": {"$ size": 3 }})
Fuzzy query:
Db. collname. find ({"actors. name":/Catterfeld/I}, {"tag": 1, "_ id": 1, "actors": 1 })
Reference recommendations:
MongoDB query (array, embedded document, and $ where)
Common mongodb commands
MongoDB Query