One, Mongodb projection
Projection means that you select only the data for the field you want, rather than selecting the data for the entire document field. (That is, return the specified field)
The second parameter of the Find method is the Set field display parameter 1 shows the current field 0 hides the current field
Find ({},{key:1})
Two, MongoDB limit record number
Limit (number) returns the number bar data
Skip (number) Skips the result of the query to the number bar data returned
Third, MongoDB sort
Sort ({key:1}) sorted ascending by key field 1 Ascending-1 descending
Iv. MongoDB Set Index
Improve query efficiency, you can create a single index to create a composite index
Key: Name of the field that created the index 1 ascending-1 Creating an index in descending order
Ensureindex ({key:1},{unique:true}) CREATE index
Background: Create an index in the background. So that building an index does not prevent other database activities
Unique: Create a unique index
Name: Index names
Five, MongoDB aggregation query
Aggregate ()
$sum summation
$avg mean value
$min Minimum value
$max Maximum Value
$push adding values to the array can be repeated
$addToSet adds a value to the array, but does not create duplicates
MongoDB Learning (iv)