@@ -60,8 +60,9 @@ export class ClientBulkWriteCommandBuilder {
60
60
const namespaces = new Map < string , number > ( ) ;
61
61
for ( const model of this . models ) {
62
62
const ns = model . namespace ;
63
- if ( namespaces . has ( ns ) ) {
64
- operations . push ( buildOperation ( model , namespaces . get ( ns ) as number ) ) ;
63
+ const index = namespaces . get ( ns ) ;
64
+ if ( index != null ) {
65
+ operations . push ( buildOperation ( model , index ) ) ;
65
66
} else {
66
67
namespaces . set ( ns , currentNamespaceIndex ) ;
67
68
operations . push ( buildOperation ( model , currentNamespaceIndex ) ) ;
@@ -92,7 +93,7 @@ export class ClientBulkWriteCommandBuilder {
92
93
}
93
94
94
95
/** @internal */
95
- export interface InsertOperation < TSchema extends Document = Document > {
96
+ interface ClientInsertOperation < TSchema extends Document = Document > {
96
97
insert : number ;
97
98
document : OptionalId < TSchema > ;
98
99
}
@@ -103,16 +104,19 @@ export interface InsertOperation<TSchema extends Document = Document> {
103
104
* @param index - The namespace index.
104
105
* @returns the operation.
105
106
*/
106
- export const buildInsertOneOperation = ( model : ClientInsertOneModel , index : number ) : Document => {
107
- const document : InsertOperation = {
107
+ export const buildInsertOneOperation = (
108
+ model : ClientInsertOneModel ,
109
+ index : number
110
+ ) : ClientInsertOperation => {
111
+ const document : ClientInsertOperation = {
108
112
insert : index ,
109
113
document : model . document
110
114
} ;
111
115
return document ;
112
116
} ;
113
117
114
118
/** @internal */
115
- export interface DeleteOperation < TSchema extends Document = Document > {
119
+ export interface ClientDeleteOperation < TSchema extends Document = Document > {
116
120
delete : number ;
117
121
multi : boolean ;
118
122
filter : Filter < TSchema > ;
@@ -147,8 +151,8 @@ function createDeleteOperation(
147
151
model : ClientDeleteOneModel | ClientDeleteManyModel ,
148
152
index : number ,
149
153
multi : boolean
150
- ) : DeleteOperation {
151
- const document : DeleteOperation = {
154
+ ) : ClientDeleteOperation {
155
+ const document : ClientDeleteOperation = {
152
156
delete : index ,
153
157
multi : multi ,
154
158
filter : model . filter
@@ -163,7 +167,7 @@ function createDeleteOperation(
163
167
}
164
168
165
169
/** @internal */
166
- export interface UpdateOperation < TSchema extends Document = Document > {
170
+ export interface ClientUpdateOperation < TSchema extends Document = Document > {
167
171
update : number ;
168
172
multi : boolean ;
169
173
filter : Filter < TSchema > ;
@@ -182,7 +186,7 @@ export interface UpdateOperation<TSchema extends Document = Document> {
182
186
export const buildUpdateOneOperation = (
183
187
model : ClientUpdateOneModel ,
184
188
index : number
185
- ) : UpdateOperation => {
189
+ ) : ClientUpdateOperation => {
186
190
return createUpdateOperation ( model , index , false ) ;
187
191
} ;
188
192
@@ -195,7 +199,7 @@ export const buildUpdateOneOperation = (
195
199
export const buildUpdateManyOperation = (
196
200
model : ClientUpdateManyModel ,
197
201
index : number
198
- ) : UpdateOperation => {
202
+ ) : ClientUpdateOperation => {
199
203
return createUpdateOperation ( model , index , true ) ;
200
204
} ;
201
205
@@ -206,8 +210,8 @@ function createUpdateOperation(
206
210
model : ClientUpdateOneModel | ClientUpdateManyModel ,
207
211
index : number ,
208
212
multi : boolean
209
- ) : UpdateOperation {
210
- const document : UpdateOperation = {
213
+ ) : ClientUpdateOperation {
214
+ const document : ClientUpdateOperation = {
211
215
update : index ,
212
216
multi : multi ,
213
217
filter : model . filter ,
@@ -226,7 +230,7 @@ function createUpdateOperation(
226
230
}
227
231
228
232
/** @internal */
229
- export interface ReplaceOneOperation < TSchema extends Document = Document > {
233
+ export interface ClientReplaceOneOperation < TSchema extends Document = Document > {
230
234
update : number ;
231
235
multi : boolean ;
232
236
filter : Filter < TSchema > ;
@@ -244,8 +248,8 @@ export interface ReplaceOneOperation<TSchema extends Document = Document> {
244
248
export const buildReplaceOneOperation = (
245
249
model : ClientReplaceOneModel ,
246
250
index : number
247
- ) : ReplaceOneOperation => {
248
- const document : ReplaceOneOperation = {
251
+ ) : ClientReplaceOneOperation => {
252
+ const document : ClientReplaceOneOperation = {
249
253
update : index ,
250
254
multi : false ,
251
255
filter : model . filter ,
0 commit comments