On this Page
Snap type: | Write | |||||||
---|---|---|---|---|---|---|---|---|
Description: | This Snap deletes some or all documents in a MongoDB collection.
| |||||||
Prerequisites: | [None] | |||||||
Support and limitations: |
| |||||||
Account: | This Snap uses account references created on the Accounts page of SnapLogic Manager to handle access to this endpoint. See MongoDB Account for information on setting up this type of account. | |||||||
Views: |
| |||||||
Settings | ||||||||
Label | Required. The name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline. | |||||||
Database name | The database that the collection is defined in. If not specified, then the MongoDB account database will be used. Example: assets | |||||||
Collection name | Required. Select or enter a MongoDB collection name. | |||||||
Delete query | The delete query represents the remove query parameter. It is an expression that evaluates to an object or JSON string. If no delete query is defined, then all records will be removed from the collection. When the expression evaluates to an object, only strict mode is supported. When the expression evaluates to a JSON string, both strict mode and mongo shell mode are supported. More information about MongoDB Extended JSON can be found here. Example: (with '=' button pressed/expression enabled) $id represents an integer in this example.
or
Default value: [None] | |||||||
Allow delete all | If this property is selected and the Delete query is empty, all documents are deleted from the selected collection. Default value: Not selected | |||||||
Pass through | If selected, the input document will be passed through to the output views under the key 'original'. The document will be passed to the Parameter output view, and it will also be passed to the Result Set output view if there is output sent from this view. | |||||||
The upstream schema suggest is only supported if the defined collection provides data. MongoDB does not provide a metadata API to describe the collection, so the SnapLogic platform looks at the data and derives the schema from it. |
In this pipeline, we shall:
1. Using the MongoDB Delete Snap, delete the existing documents from the collection, mongodb_collection2. The respective output preview displays that the three documents are deleted from the collection:
2. Supply the new documents to be inserted into the MongoDB collection through the JSON Generator Snap.
3. Insert the documents into the collection name, mongodb_collection2 using the MongoDB Insert Snap. The respective output preview displayed is as below:
4. Delete the required documents from the collection, mongodb_collection2, by giving the delete query, {age:{ $gte:30}. This would delete all the documents where the age of a person is greater than or equal to 30 years.
5. The successful execution of the pipeline displays the below output preview (Four Documents that satisfy the delete query are deleted):