MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / create

Function create

packages/core/fumadb/src/adapters/mongodb/query.ts:415–437  ·  view source on GitHub ↗
(table, values)

Source from the content-addressed store, hash-verified

413 );
414 },
415 async create(table, values) {
416 const collection = db.collection(table.names.mongodb);
417 const { insertedId } = await collection.insertOne(
418 mapInsertValues(values, table),
419 { session }
420 );
421
422 const result = await collection.findOne(
423 {
424 _id: insertedId,
425 },
426 {
427 session,
428 projection: mapProjection(true, table),
429 }
430 );
431
432 if (result === null)
433 throw new Error(
434 "Failed to insert document: cannot find inserted coument."
435 );
436 return mapResult(result, table);
437 },
438 async createMany(table, values) {
439 const idField = table.getIdColumn().names.mongodb;
440 values = values.map((v) => mapInsertValues(v, table));

Callers

nothing calls this directly

Calls 3

mapInsertValuesFunction · 0.85
mapProjectionFunction · 0.85
mapResultFunction · 0.70

Tested by

no test coverage detected