(table, values)
| 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)); |
nothing calls this directly
no test coverage detected