@@ -37,7 +37,7 @@ import type {
3737 ServerApiVersion ,
3838 WriteConcern ,
3939 AnyClientBulkWriteModel ,
40- ClientBulkWriteResult ,
40+ ClientBulkWriteOptions ,
4141} from '@mongosh/service-provider-core' ;
4242import type { ConnectionInfo } from '@mongosh/arg-parser' ;
4343import {
@@ -47,6 +47,7 @@ import {
4747import type Collection from './collection' ;
4848import Database from './database' ;
4949import type ShellInstanceState from './shell-instance-state' ;
50+ import { ClientBulkWriteResult } from './result' ;
5051import { CommandResult } from './result' ;
5152import { redactURICredentials } from '@mongosh/history' ;
5253import { asPrintable , ServerVersions , Topologies } from './enums' ;
@@ -64,7 +65,6 @@ import { ShellApiErrors } from './error-codes';
6465import type { LogEntry } from './log-entry' ;
6566import { parseAnyLogEntry } from './log-entry' ;
6667import type { ShellBson } from './shell-bson' ;
67- import type { ClientBulkWriteOptions } from 'mongodb' ;
6868
6969/* Utility, inverse of Readonly<T> */
7070type Mutable < T > = {
@@ -371,13 +371,35 @@ export default class Mongo extends ShellApiClass {
371371 @returnsPromise
372372 @serverVersions ( [ '8.0.0' , ServerVersions . latest ] )
373373 @apiVersions ( [ 1 ] )
374- bulkWrite (
374+ async bulkWrite (
375375 models : AnyClientBulkWriteModel < Document > [ ] ,
376376 options : ClientBulkWriteOptions = { }
377377 ) : Promise < ClientBulkWriteResult > {
378378 this . _emitMongoApiCall ( 'bulkWrite' , { options } ) ;
379379
380- return this . _serviceProvider . clientBulkWrite ( models , options ) ;
380+ const {
381+ acknowledged,
382+ insertedCount,
383+ matchedCount,
384+ modifiedCount,
385+ deletedCount,
386+ upsertedCount,
387+ insertResults,
388+ updateResults,
389+ deleteResults,
390+ } = await this . _serviceProvider . clientBulkWrite ( models , options ) ;
391+
392+ return new ClientBulkWriteResult ( {
393+ acknowledged,
394+ insertedCount,
395+ matchedCount,
396+ modifiedCount,
397+ deletedCount,
398+ upsertedCount,
399+ insertResults,
400+ updateResults,
401+ deleteResults,
402+ } ) ;
381403 }
382404
383405 @returnsPromise
0 commit comments