MongoDB icon

MongoDB

MongoDB custom node with singleton pooling, insert if not exists, update operators and advanced querying

Insert One

AI-generated

Summary

Insert a single document into the specified MongoDB collection within the given database.

Inputs

  • Database (required) — The name of the MongoDB database where the document will be inserted.
  • Collection (required) — The name of the MongoDB collection to insert the document into.
  • Document (required) — The fields and their values that compose the document to insert. Each field requires a key (field name), a type (one of: string, number, boolean, datetime, uuid), and a corresponding value.

Output shape

An array containing a single object with the inserted document's ID under the 'id' property.

The returned 'id' corresponds to the MongoDB insertedId of the new document. Any errors during insertion are thrown unless the node is configured to continue on failure.

Examples

Example 1: Insert a new user document with name and age fields

Database: myDatabase, Collection: users, Document fields: [{key: 'name', type: 'string', value: 'Alice'}, {key: 'age', type: 'number', value: '30'}]

Links

Discussion