MongoDB Ex icon

MongoDB Ex

MongoDB Extended - Advanced MongoDB operations, including support for filters, bulk operations, full update JSON support and more.

Document → Insert

AI-generated

Summary

Inserts documents into a MongoDB collection.

Inputs

  • collection (required) — MongoDB Collection to insert into.
  • document (required) — Document to insert. When Many is enabled, supply an array of documents for insertMany.
  • ordered (required) — Whether to execute the operation in order and stop on the first error.
  • options (required) — Additional MongoDB operation options such as timeout, maxTime, hint, or arrayFilters.
  • many (required) — Whether to perform a multi-document operation (insertMany) instead of a single insert.

Output shape

an array of inserted document records, each containing the inserted document and its generated _id

Returns an empty array if no documents are inserted; the operation fails if ordered is true and an error occurs.

Examples

Example 1: Insert a single document

collection: users; document: {"name":"Bob","role":"admin"}; ordered: false

Example 2: Insert multiple documents using insertMany

collection: orders; document:[{"id":1},{"id":2}]; many: true; ordered: true

Discussion