@@ -25,11 +25,15 @@ import type { Hint } from '../operations/operation';
25
25
// Error codes
26
26
const WRITE_CONCERN_ERROR = 64 ;
27
27
28
- export enum BatchType {
29
- INSERT = 1 ,
30
- UPDATE = 2 ,
31
- REMOVE = 3
32
- }
28
+ /** @public */
29
+ export const BatchType = {
30
+ INSERT : 1 ,
31
+ UPDATE : 2 ,
32
+ REMOVE : 3
33
+ } as const ;
34
+
35
+ /** @public */
36
+ export type BatchTypeId = typeof BatchType [ keyof typeof BatchType ] ;
33
37
34
38
/** @public */
35
39
export interface InsertOneModel {
@@ -115,7 +119,7 @@ export type AnyBulkWriteOperation =
115
119
| { deleteOne : DeleteOneModel }
116
120
| { deleteMany : DeleteManyModel } ;
117
121
118
- /** @internal */
122
+ /** @public */
119
123
export interface BulkResult {
120
124
ok : number ;
121
125
writeErrors : WriteError [ ] ;
@@ -133,17 +137,19 @@ export interface BulkResult {
133
137
/**
134
138
* Keeps the state of a unordered batch so we can rewrite the results
135
139
* correctly after command execution
140
+ *
141
+ * @internal
136
142
*/
137
143
export class Batch {
138
144
originalZeroIndex : number ;
139
145
currentIndex : number ;
140
146
originalIndexes : number [ ] ;
141
- batchType : BatchType ;
147
+ batchType : BatchTypeId ;
142
148
operations : Document [ ] ;
143
149
size : number ;
144
150
sizeBytes : number ;
145
151
146
- constructor ( batchType : BatchType , originalZeroIndex : number ) {
152
+ constructor ( batchType : BatchTypeId , originalZeroIndex : number ) {
147
153
this . originalZeroIndex = originalZeroIndex ;
148
154
this . currentIndex = 0 ;
149
155
this . originalIndexes = [ ] ;
@@ -348,7 +354,7 @@ export class WriteConcernError {
348
354
}
349
355
}
350
356
351
- /** @internal */
357
+ /** @public */
352
358
export interface BulkWriteOperationError {
353
359
index : number ;
354
360
code : number ;
@@ -704,8 +710,10 @@ export class MongoBulkWriteError extends MongoError {
704
710
/**
705
711
* A builder object that is returned from {@link BulkOperationBase#find}.
706
712
* Is used to build a write operation that involves a query filter.
713
+ *
714
+ * @public
707
715
*/
708
- class FindOperators {
716
+ export class FindOperators {
709
717
bulkOperation : BulkOperationBase ;
710
718
711
719
/**
@@ -855,16 +863,17 @@ class FindOperators {
855
863
return this . bulkOperation . addToOperationsList ( BatchType . REMOVE , document ) ;
856
864
}
857
865
858
- removeOne ( ) {
866
+ removeOne ( ) : BulkOperationBase {
859
867
return this . deleteOne ( ) ;
860
868
}
861
869
862
- remove ( ) {
870
+ remove ( ) : BulkOperationBase {
863
871
return this . delete ( ) ;
864
872
}
865
873
}
866
874
867
- interface BulkOperationPrivate {
875
+ /** @internal */
876
+ export interface BulkOperationPrivate {
868
877
bulkResult : BulkResult ;
869
878
currentBatch ?: Batch ;
870
879
currentIndex : number ;
@@ -916,8 +925,10 @@ export interface BulkWriteOptions extends CommandOperationOptions {
916
925
forceServerObjectId ?: boolean ;
917
926
}
918
927
928
+ /** @public */
919
929
export abstract class BulkOperationBase {
920
930
isOrdered : boolean ;
931
+ /** @internal */
921
932
s : BulkOperationPrivate ;
922
933
operationId ?: number ;
923
934
@@ -1263,7 +1274,7 @@ export abstract class BulkOperationBase {
1263
1274
}
1264
1275
1265
1276
abstract addToOperationsList (
1266
- batchType : BatchType ,
1277
+ batchType : BatchTypeId ,
1267
1278
document : Document | UpdateStatement | DeleteStatement
1268
1279
) : this;
1269
1280
}
@@ -1301,7 +1312,7 @@ function shouldForceServerObjectId(bulkOperation: BulkOperationBase): boolean {
1301
1312
return false ;
1302
1313
}
1303
1314
1304
- /** @internal */
1315
+ /** @public */
1305
1316
export interface UpdateStatement {
1306
1317
/** The query that matches documents to update. */
1307
1318
q : Document ;
@@ -1368,7 +1379,7 @@ function isUpdateStatement(model: Document): model is UpdateStatement {
1368
1379
return 'q' in model ;
1369
1380
}
1370
1381
1371
- /** @internal */
1382
+ /** @public */
1372
1383
export interface DeleteStatement {
1373
1384
/** The query that matches documents to delete. */
1374
1385
q : Document ;
0 commit comments