MongoDB Write
MongoDBWrite
Section titled “MongoDBWrite ”MongoDBWrite performs write operations on a Mongo database.
Mongo is a NoSql database, which provides a mechanism for storage and retrieval of data that is different to the tabular relations used in relational databases like SQL Server, MySql and Oracle.
Properties
Section titled “Properties ”Connection string
Section titled “Connection string ”Configuration values required by the data provider to connect to the data source. learn more
Collection
Section titled “Collection ”The collection to write to.
Operation
Section titled “Operation ”The operation to perform.
Options:
- Insert
Inserts a single object (specified in the data property) into the database. - Update
Applies an update operation to any documents in the database that matches the criteria property. - Replace
Replaces a single document in the database with the object in the data property. The document to be replaced can either be specified by the criteria property, or by the ID attribute of the replacement document. - Delete
Deletes one or more documents in the database which match the criteria property. - Delete All
Deletes all records in the collection.
The selection of an Operation will determine which specific properties will display for you to complete.
Insert
Section titled “Insert”Data
The object to be written into the database. The object can be specified either as a JSON formatted string, or as an instance of a Type.
Update
Section titled “Update”Criteria
A MongoDb query document that specifies the selection criteria to be matched by a document in order for it to have the write operation applied.
For example, if we select from collection of documents with attributes “quantity” and “price”, the following criteria will match all documents in the collection with fields “quantity” greater than 100 or “price” less than 9.95.:
{ $or: [ { quantity: { $gt: 100 } }, { price: { $lt: 9.95 } } ] }
Click on … to acess the Criteria Editor to add database fields and variables to the criteria.
Insert If Not Found
Controls the action of replace and update operations, when no documents are found matching the criteria property.
- Checked - A new document will be created.
- Unchecked - No action will be taken.
Update Operation
JSON object describing the changes to be made to each database document.
Click on … to acess the Update Operation Editor, where you can formulate your update operations.
The following example will set an updated field to ‘true’ and increment a count field for all matched documents.:
{ $set: { updated: true }, $inc: { count: 1 } }
Replace
Section titled “Replace”Criteria
A MongoDb query document that specifies the selection criteria to be matched by a document in order for it to have the write operation applied.
For example, if we select from collection of documents with attributes “quantity” and “price”, the following criteria will match all documents in the collection with fields “quantity” greater than 100 or “price” less than 9.95.:
{ $or: [ { quantity: { $gt: 100 } }, { price: { $lt: 9.95 } } ] }
Click on … to acess the Criteria Editor to add database fields and variables to the criteria.
Data
The object to be written into the database. The object can be specified either as a JSON formatted string, or as an instance of a Type.
Insert If Not Found
Controls the action of replace and update operations, when no documents are found matching the criteria property.
- Checked - A new document will be created.
- Unchecked - No action will be taken.
Delete
Section titled “Delete”Criteria
A MongoDb query document that specifies the selection criteria to be matched by a document in order for it to have the write operation applied.
For example, if we select from collection of documents with attributes “quantity” and “price”, the following criteria will match all documents in the collection with fields “quantity” greater than 100 or “price” less than 9.95.:
{ $or: [ { quantity: { $gt: 100 } }, { price: { $lt: 9.95 } } ] }
Click on … to acess the Criteria Editor to add database fields and variables to the criteria.
DeleteAll
Section titled “DeleteAll”No specific additional properties.
What are ID Attributes?
Section titled “What are ID Attributes? ”Each document in a MongoDb collection is uniquely identified by an Object ID field called “_id”. This field is automatically created whenever a new document is inserted into the database, and cannot be changed by update or replace operations.
When using the object id as an element in the criteria field, the string value will need to be converted back to a Mongo object id. For example, a document with id “525bc19331eec126ecdcf199” can be matched by using the criteria:
{ _id: ObjectId("525bc19331eec126ecdcf199") }
When running a replace operation without specifying any criteria, the function will attempt to replace a document in the database whose id matches a string field named “id” or “_id” in the replacement object. This allows objects to be read from the database using the MongoDBRead function, altered and written back to the database without requiring a replacement criteria.