mongoose of CRUD
-C creat:
Model objects .create (document object, the callback function)
Model objects .create (document object)
-R Read:
Model object .find (query, [projection]) Note ⚠️: with or without data, returns an array
Model object .findOne (query, projection]) Note ⚠️: find returns an object, returns an array not found
-U update
Model object .updateOne (query, you want to update content, [configuration object])
Model object .updateMany (query, you want to update content, [configuration object])
Note ⚠️: update methods exist, but soon abandoned the query to match multiple time, still only a modification, the proposed updateOne
-D delete
Model object .deleteOne (query)
Model object .deleteMany (query)
Note ⚠️: no delete method, wrong return
all of the above, if you do not specify a callback function, the return value is a promise Object