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

Function maybeAddIdToDocuments

src/utils.ts:1302–1320  ·  view source on GitHub ↗
(
  collection: Collection,
  document: Document,
  options: { forceServerObjectId?: boolean }
)

Source from the content-addressed store, hash-verified

1300}
1301
1302export function maybeAddIdToDocuments(
1303 collection: Collection,
1304 document: Document,
1305 options: { forceServerObjectId?: boolean }
1306): Document {
1307 const forceServerObjectId =
1308 options.forceServerObjectId ?? collection.db.options?.forceServerObjectId ?? false;
1309
1310 // no need to modify the docs if server sets the ObjectId
1311 if (forceServerObjectId) {
1312 return document;
1313 }
1314
1315 if (document._id == null) {
1316 document._id = collection.s.pkFactory.createPk();
1317 }
1318
1319 return document;
1320}
1321
1322export async function fileIsAccessible(fileName: string, mode?: number) {
1323 try {

Callers 3

insertFunction · 0.90
rawFunction · 0.90
constructorMethod · 0.90

Calls 1

createPkMethod · 0.80

Tested by

no test coverage detected