The simplest query is that MongoDB is an object-oriented one.
For example, the simplest query is only three data for the entire data set
First query for data with name Zhang San
The condition of the query is relatively good write arbitrary db.collection.find (query condition) for example
15
The result is this.
If you do not want to return a field, you can define the value of the returned field as a syntax such as Db.collection.find ({query Criteria},{return field})
16
We see that every time the query "_id" is returned, we can set it to 0 so that it does not return
Such as
The value in the key-value pair in the query condition needs to be constant so the query is not allowed > db.student.find ({"Name": "This.sex"})
Query criteria Symbols
$lt less than
$lte less than or equal
$GT Greater than
$gte greater than or equal
$in in
$nin not in
$or or
$mod
$nod Not Equal mode
For example, to query students younger than 20
18
Or query students who are older than 18 and less than 26
19
The query is basically like this.
Students aged 18 or 25 $in grammar
20
$or db.collection.find ({"$or": [{Condition0},{condition1}]})
$or syntax
The query condition is the smallest unit and can be as simple as it {"name": "Zhangsan"} name is Zhang San
can also be complex as it {"$or": [{"name": {"$in": ["Zhangsan", "Lisi"]}},{"age": {"$lt": +, "$GT": +}}]}
The name is Zhang San or John Doe, or the age is less than 26 or greater than 18.
It is necessary to say MONGO's date type
The new Date () returns a date Object and the date () returns a string of type strings that JavaScript is doing, if mixed. There will be problems when querying, updating, or deleting, so be careful when using the date type. In addition, the date object is comparable in size (the number of milliseconds stored in the new era to the current time (Greenwich)), and the string I first hehe
You can do a little experiment to make a difference.
Continue exploring tomorrow.