Connect to MongoDB
Create a MongoDB connection, that later you can query:
In the next example, you will learn how to query the connection object.
This extension close the connection automatically, it's not necessary to close manually.
Delete a document
Example for deleting all documents where name is equal to "Peter":
Get multiple documents - find()
Example for searching multiple users with the name "Mike":
Get one document - findOne()
Example for searching just one user with a specific id, you should do:
Example for adding a document:
Update a document
Example for updating all documents where name is equal to "John":
This modified text is an extract of the original Stack Overflow Documentation created by following contributors
and released under CC BY-SA 3.0