@@ -269,10 +269,6 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
269
269
public async insertMany ( documents : MaybeId < Schema > [ ] , options ?: InsertManyOptions ) : Promise < InsertManyResult < Schema > > {
270
270
const chunkSize = options ?. chunkSize ?? 20 ;
271
271
272
- if ( options ?. vectors && options ?. vectorize ) {
273
- throw new Error ( 'Cannot set both vectors and vectorize options' ) ;
274
- }
275
-
276
272
if ( options ?. vectors ) {
277
273
if ( options . vectors . length !== documents . length ) {
278
274
throw new Error ( 'The number of vectors must match the number of documents' ) ;
@@ -292,6 +288,9 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
292
288
293
289
for ( let i = 0 , n = documents . length ; i < n ; i ++ ) {
294
290
if ( options . vectorize [ i ] ) {
291
+ if ( documents [ i ] . $vector ) {
292
+ throw new Error ( 'Vector and vectorize options cannot overlap' ) ;
293
+ }
295
294
documents [ i ] = { ...documents [ i ] , $vectorize : options . vectorize [ i ] } ;
296
295
}
297
296
}
@@ -353,7 +352,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
353
352
* @see StrictFilter
354
353
* @see StrictUpdateFilter
355
354
*/
356
- public async updateOne ( filter : Filter < Schema > , update : UpdateFilter < Schema > , options ?: UpdateOneOptions < Schema > ) : Promise < UpdateOneResult < Schema > > {
355
+ public async updateOne ( filter : Filter < Schema > , update : UpdateFilter < Schema > , options ?: UpdateOneOptions ) : Promise < UpdateOneResult < Schema > > {
357
356
options = coalesceVectorSpecialsIntoSort ( options ) ;
358
357
359
358
const command : UpdateOneCommand = {
@@ -541,7 +540,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
541
540
*
542
541
* @see StrictFilter
543
542
*/
544
- public async replaceOne ( filter : Filter < Schema > , replacement : NoId < Schema > , options ?: ReplaceOneOptions < Schema > ) : Promise < ReplaceOneResult < Schema > > {
543
+ public async replaceOne ( filter : Filter < Schema > , replacement : NoId < Schema > , options ?: ReplaceOneOptions ) : Promise < ReplaceOneResult < Schema > > {
545
544
options = coalesceVectorSpecialsIntoSort ( options ) ;
546
545
547
546
const command : FindOneAndReplaceCommand = {
@@ -608,7 +607,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
608
607
*
609
608
* @see StrictFilter
610
609
*/
611
- public async deleteOne ( filter : Filter < Schema > = { } , options ?: DeleteOneOptions < Schema > ) : Promise < DeleteOneResult > {
610
+ public async deleteOne ( filter : Filter < Schema > = { } , options ?: DeleteOneOptions ) : Promise < DeleteOneResult > {
612
611
options = coalesceVectorSpecialsIntoSort ( options ) ;
613
612
614
613
const command : DeleteOneCommand = {
@@ -783,7 +782,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
783
782
* the Data API and the client periodically exchange new chunks of documents.
784
783
* It should be noted that the behavior of the cursor in the case documents
785
784
* have been added/removed after the `find` was started depends on database
786
- * internals and it is not guaranteed, nor excluded, that such "real-time"
785
+ * internals, and it is not guaranteed, nor excluded, that such "real-time"
787
786
* changes in the data would be picked up by the cursor.
788
787
*
789
788
* @param filter - A filter to select the documents to find. If not provided, all documents will be returned.
@@ -793,7 +792,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
793
792
*
794
793
* @see StrictFilter
795
794
*/
796
- find < GetSim extends boolean = false > ( filter : Filter < Schema > , options ?: FindOptions < Schema , GetSim > ) : FindCursor < FoundDoc < Schema , GetSim > , FoundDoc < Schema , GetSim > > {
795
+ find < GetSim extends boolean = false > ( filter : Filter < Schema > , options ?: FindOptions < GetSim > ) : FindCursor < FoundDoc < Schema , GetSim > , FoundDoc < Schema , GetSim > > {
797
796
return new FindCursor ( this . namespace , this . _httpClient , filter as any , coalesceVectorSpecialsIntoSort ( options ) ) as any ;
798
797
}
799
798
@@ -931,7 +930,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
931
930
*
932
931
* @see StrictFilter
933
932
*/
934
- public async findOne < GetSim extends boolean = false > ( filter : Filter < Schema > , options ?: FindOneOptions < Schema , GetSim > ) : Promise < FoundDoc < Schema , GetSim > | null > {
933
+ public async findOne < GetSim extends boolean = false > ( filter : Filter < Schema > , options ?: FindOneOptions < GetSim > ) : Promise < FoundDoc < Schema , GetSim > | null > {
935
934
options = coalesceVectorSpecialsIntoSort ( options ) ;
936
935
937
936
const command : FindOneCommand = {
@@ -1059,7 +1058,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
1059
1058
public async findOneAndReplace (
1060
1059
filter : Filter < Schema > ,
1061
1060
replacement : NoId < Schema > ,
1062
- options : FindOneAndReplaceOptions < Schema > & { includeResultMetadata : true } ,
1061
+ options : FindOneAndReplaceOptions & { includeResultMetadata : true } ,
1063
1062
) : Promise < ModifyResult < Schema > >
1064
1063
1065
1064
/**
@@ -1103,10 +1102,10 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
1103
1102
public async findOneAndReplace (
1104
1103
filter : Filter < Schema > ,
1105
1104
replacement : NoId < Schema > ,
1106
- options : FindOneAndReplaceOptions < Schema > & { includeResultMetadata ?: false } ,
1105
+ options : FindOneAndReplaceOptions & { includeResultMetadata ?: false } ,
1107
1106
) : Promise < WithId < Schema > | null >
1108
1107
1109
- public async findOneAndReplace ( filter : Filter < Schema > , replacement : NoId < Schema > , options : FindOneAndReplaceOptions < Schema > ) : Promise < ModifyResult < Schema > | WithId < Schema > | null > {
1108
+ public async findOneAndReplace ( filter : Filter < Schema > , replacement : NoId < Schema > , options : FindOneAndReplaceOptions ) : Promise < ModifyResult < Schema > | WithId < Schema > | null > {
1110
1109
options = coalesceVectorSpecialsIntoSort ( options ) ;
1111
1110
1112
1111
const command : FindOneAndReplaceCommand = {
@@ -1175,7 +1174,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
1175
1174
*/
1176
1175
public async findOneAndDelete (
1177
1176
filter : Filter < Schema > ,
1178
- options : FindOneAndDeleteOptions < Schema > & { includeResultMetadata : true } ,
1177
+ options : FindOneAndDeleteOptions & { includeResultMetadata : true } ,
1179
1178
) : Promise < ModifyResult < Schema > >
1180
1179
1181
1180
/**
@@ -1207,10 +1206,10 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
1207
1206
*/
1208
1207
public async findOneAndDelete (
1209
1208
filter : Filter < Schema > ,
1210
- options ?: FindOneAndDeleteOptions < Schema > & { includeResultMetadata ?: false } ,
1209
+ options ?: FindOneAndDeleteOptions & { includeResultMetadata ?: false } ,
1211
1210
) : Promise < WithId < Schema > | null >
1212
1211
1213
- public async findOneAndDelete ( filter : Filter < Schema > , options ?: FindOneAndDeleteOptions < Schema > ) : Promise < ModifyResult < Schema > | WithId < Schema > | null > {
1212
+ public async findOneAndDelete ( filter : Filter < Schema > , options ?: FindOneAndDeleteOptions ) : Promise < ModifyResult < Schema > | WithId < Schema > | null > {
1214
1213
options = coalesceVectorSpecialsIntoSort ( options ) ;
1215
1214
1216
1215
const command : FindOneAndDeleteCommand = {
@@ -1277,7 +1276,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
1277
1276
public async findOneAndUpdate (
1278
1277
filter : Filter < Schema > ,
1279
1278
update : UpdateFilter < Schema > ,
1280
- options : FindOneAndUpdateOptions < Schema > & { includeResultMetadata : true } ,
1279
+ options : FindOneAndUpdateOptions & { includeResultMetadata : true } ,
1281
1280
) : Promise < ModifyResult < Schema > >
1282
1281
1283
1282
/**
@@ -1318,10 +1317,10 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
1318
1317
public async findOneAndUpdate (
1319
1318
filter : Filter < Schema > ,
1320
1319
update : UpdateFilter < Schema > ,
1321
- options : FindOneAndUpdateOptions < Schema > & { includeResultMetadata ?: false } ,
1320
+ options : FindOneAndUpdateOptions & { includeResultMetadata ?: false } ,
1322
1321
) : Promise < WithId < Schema > | null >
1323
1322
1324
- public async findOneAndUpdate ( filter : Filter < Schema > , update : UpdateFilter < Schema > , options : FindOneAndUpdateOptions < Schema > ) : Promise < ModifyResult < Schema > | WithId < Schema > | null > {
1323
+ public async findOneAndUpdate ( filter : Filter < Schema > , update : UpdateFilter < Schema > , options : FindOneAndUpdateOptions ) : Promise < ModifyResult < Schema > | WithId < Schema > | null > {
1325
1324
options = coalesceVectorSpecialsIntoSort ( options ) ;
1326
1325
1327
1326
const command : FindOneAndUpdateCommand = {
0 commit comments