@@ -1357,38 +1357,23 @@ export async function once<T>(ee: EventEmitter, name: string, options?: Abortabl
13571357}
13581358
13591359export function maybeAddIdToDocuments (
1360- coll : Collection ,
1361- docs : Document [ ] ,
1360+ collection : Collection ,
1361+ document : Document ,
13621362 options : { forceServerObjectId ?: boolean }
1363- ) : Document [ ] ;
1364- export function maybeAddIdToDocuments (
1365- coll : Collection ,
1366- docs : Document ,
1367- options : { forceServerObjectId ?: boolean }
1368- ) : Document ;
1369- export function maybeAddIdToDocuments (
1370- coll : Collection ,
1371- docOrDocs : Document [ ] | Document ,
1372- options : { forceServerObjectId ?: boolean }
1373- ) : Document [ ] | Document {
1363+ ) : Document {
13741364 const forceServerObjectId =
1375- typeof options . forceServerObjectId === 'boolean'
1376- ? options . forceServerObjectId
1377- : coll . s . db . options ?. forceServerObjectId ;
1365+ options . forceServerObjectId ?? collection . s . db . options ?. forceServerObjectId ?? false ;
13781366
13791367 // no need to modify the docs if server sets the ObjectId
1380- if ( forceServerObjectId === true ) {
1381- return docOrDocs ;
1368+ if ( forceServerObjectId ) {
1369+ return document ;
13821370 }
13831371
1384- const transform = ( doc : Document ) : Document => {
1385- if ( doc . _id == null ) {
1386- doc . _id = coll . s . pkFactory . createPk ( ) ;
1387- }
1372+ if ( document . _id == null ) {
1373+ document . _id = collection . s . pkFactory . createPk ( ) ;
1374+ }
13881375
1389- return doc ;
1390- } ;
1391- return Array . isArray ( docOrDocs ) ? docOrDocs . map ( transform ) : transform ( docOrDocs ) ;
1376+ return document ;
13921377}
13931378
13941379export async function fileIsAccessible ( fileName : string , mode ?: number ) {
0 commit comments