MCPcopy
hub / github.com/mongodb/node-mongodb-native / insertOne

Method insertOne

src/collection.ts:290–302  ·  src/collection.ts::Collection.insertOne

* Inserts a single document into MongoDB. If documents passed in do not contain the **_id** field, * one will be added to each of the documents missing it by the driver, mutating the document. This behavior * can be overridden by setting the **forceServerObjectId** flag. * * @param doc -

(
    doc: OptionalUnlessRequiredId<TSchema>,
    options?: InsertOneOptions
  )

Source from the content-addressed store, hash-verified

288 * @param options - Optional settings for the command
289 */
290 async insertOne(
291 doc: OptionalUnlessRequiredId<TSchema>,
292 options?: InsertOneOptions
293 ): Promise<InsertOneResult<TSchema>> {
294 return await executeOperation(
295 this.client,
296 new InsertOneOperation(
297 this as TODO_NODE_3286,
298 doc,
299 resolveOptions(this, options)
300 ) as TODO_NODE_3286
301 );
302 }
303
304 /**
305 * Inserts an array of documents into MongoDB. If documents passed in do not contain the **_id** field,

Calls 2

executeOperationFunction · 0.90
resolveOptionsFunction · 0.90

Tested by 15

commitQuorumTestFunction · 0.64
testFunction · 0.64
writeFunction · 0.64
lastWriteFunction · 0.64
useBigInt64FalseTestFunction · 0.64
insertFunction · 0.64
testFunction · 0.64
testFunction · 0.64
defineTestFunction · 0.64
deadlockTestFunction · 0.64
runProseTestsForFunction · 0.64
defineCorpusTestsFunction · 0.64