MongoDB CRUD Operations

    CRUD operationscreate,read,update, anddelete.

    Create or insert operations add newdocumentsto a. If the collection does not currently exist, insert operations will create the collection.

    MongoDB provides the following methods to insert documents into a collection:


    • New in version 3.2

    • New in version 3.2

    In MongoDB, insert operations target a singlecollection. All write operations in MongoDB areon the level of a singledocument.

    For examples, see.

    You can specifythat identify the documents to return.

    增删改查 - 图1

    For examples, see:

    Update operations modify existingin acollection. MongoDB provides the following methods to update documents of a collection:


    • New in version 3.2

    • New in version 3.2

    • New in version 3.2

    In MongoDB, update operations target a single collection. All write operations in MongoDB areatomicon the level of a single document.

    You can specify criteria, or filters, that identify the documents to update. Theseuse the same syntax as read operations.

    For examples, seeUpdate Documents.

    Delete operations remove documents from a collection. MongoDB provides the following methods to delete documents of a collection:


    • New in version 3.2

    In MongoDB, delete operations target a singlecollection. All write operations in MongoDB areon the level of a single document.

    You can specify criteria, or filters, that identify the documents to remove. Thesefiltersuse the same syntax as read operations.

    For examples, see.