(
entityName: EntityName<T>,
data: EntityDictionary<T>[],
options: NativeInsertUpdateManyOptions<T> = {},
)
| 368 | } |
| 369 | |
| 370 | async nativeInsertMany<T extends object>( |
| 371 | entityName: EntityName<T>, |
| 372 | data: EntityDictionary<T>[], |
| 373 | options: NativeInsertUpdateManyOptions<T> = {}, |
| 374 | ): Promise<QueryResult<T>> { |
| 375 | data = data.map(item => { |
| 376 | this.handleVersionProperty(entityName, item); |
| 377 | return this.renameFields(entityName, item); |
| 378 | }); |
| 379 | const meta = this.metadata.find(entityName); |
| 380 | /* v8 ignore next */ |
| 381 | const pk = meta?.getPrimaryProps()[0].fieldNames[0] ?? '_id'; |
| 382 | const res = await this.rethrow( |
| 383 | this.getConnection('write').insertMany(entityName, data as any[], options.ctx, options.signal), |
| 384 | ); |
| 385 | res.rows = res.insertedIds!.map(id => ({ [pk]: id })); |
| 386 | |
| 387 | return res as unknown as QueryResult<T>; |
| 388 | } |
| 389 | |
| 390 | async nativeUpdate<T extends object>( |
| 391 | entityName: EntityName<T>, |
nothing calls this directly
no test coverage detected