Skip to content

Commit 699af5f

Browse files
authored
Merge pull request #14118 from Automattic/vkarpov15/gh-14077
types(query): base filters and projections off of RawDocType instead of DocType so autocomplete doesn't show populate
2 parents 6def405 + 9e3185a commit 699af5f

File tree

1 file changed

+46
-46
lines changed

1 file changed

+46
-46
lines changed

types/query.d.ts

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ declare module 'mongoose' {
217217
allowDiskUse(value: boolean): this;
218218

219219
/** Specifies arguments for an `$and` condition. */
220-
and(array: FilterQuery<DocType>[]): this;
220+
and(array: FilterQuery<RawDocType>[]): this;
221221

222222
/** Specifies the batchSize option. */
223223
batchSize(val: number): this;
@@ -265,7 +265,7 @@ declare module 'mongoose' {
265265
comment(val: string): this;
266266

267267
/** Specifies this query as a `count` query. */
268-
count(criteria?: FilterQuery<DocType>): QueryWithHelpers<
268+
count(criteria?: FilterQuery<RawDocType>): QueryWithHelpers<
269269
number,
270270
DocType,
271271
THelpers,
@@ -275,7 +275,7 @@ declare module 'mongoose' {
275275

276276
/** Specifies this query as a `countDocuments` query. */
277277
countDocuments(
278-
criteria?: FilterQuery<DocType>,
278+
criteria?: FilterQuery<RawDocType>,
279279
options?: QueryOptions<DocType>
280280
): QueryWithHelpers<number, DocType, THelpers, RawDocType, 'countDocuments'>;
281281

@@ -291,10 +291,10 @@ declare module 'mongoose' {
291291
* collection, regardless of the value of `single`.
292292
*/
293293
deleteMany(
294-
filter?: FilterQuery<DocType>,
294+
filter?: FilterQuery<RawDocType>,
295295
options?: QueryOptions<DocType>
296296
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteMany'>;
297-
deleteMany(filter: FilterQuery<DocType>): QueryWithHelpers<
297+
deleteMany(filter: FilterQuery<RawDocType>): QueryWithHelpers<
298298
any,
299299
DocType,
300300
THelpers,
@@ -309,10 +309,10 @@ declare module 'mongoose' {
309309
* option.
310310
*/
311311
deleteOne(
312-
filter?: FilterQuery<DocType>,
312+
filter?: FilterQuery<RawDocType>,
313313
options?: QueryOptions<DocType>
314314
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteOne'>;
315-
deleteOne(filter: FilterQuery<DocType>): QueryWithHelpers<
315+
deleteOne(filter: FilterQuery<RawDocType>): QueryWithHelpers<
316316
any,
317317
DocType,
318318
THelpers,
@@ -324,7 +324,7 @@ declare module 'mongoose' {
324324
/** Creates a `distinct` query: returns the distinct values of the given `field` that match `filter`. */
325325
distinct<ReturnType = any>(
326326
field: string,
327-
filter?: FilterQuery<DocType>
327+
filter?: FilterQuery<RawDocType>
328328
): QueryWithHelpers<Array<ReturnType>, DocType, THelpers, RawDocType, 'distinct'>;
329329

330330
/** Specifies a `$elemMatch` query condition. When called with one argument, the most recent path passed to `where()` is used. */
@@ -364,71 +364,71 @@ declare module 'mongoose' {
364364

365365
/** Creates a `find` query: gets a list of documents that match `filter`. */
366366
find(
367-
filter: FilterQuery<DocType>,
368-
projection?: ProjectionType<DocType> | null,
367+
filter: FilterQuery<RawDocType>,
368+
projection?: ProjectionType<RawDocType> | null,
369369
options?: QueryOptions<DocType> | null
370370
): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find'>;
371371
find(
372-
filter: FilterQuery<DocType>,
373-
projection?: ProjectionType<DocType> | null
372+
filter: FilterQuery<RawDocType>,
373+
projection?: ProjectionType<RawDocType> | null
374374
): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find'>;
375375
find(
376-
filter: FilterQuery<DocType>
377-
): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find'>;
376+
filter: FilterQuery<RawDocType>
377+
): QueryWithHelpers<Array<RawDocType>, DocType, THelpers, RawDocType, 'find'>;
378378
find(): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find'>;
379379

380380
/** Declares the query a findOne operation. When executed, returns the first found document. */
381381
findOne(
382-
filter?: FilterQuery<DocType>,
383-
projection?: ProjectionType<DocType> | null,
382+
filter?: FilterQuery<RawDocType>,
383+
projection?: ProjectionType<RawDocType> | null,
384384
options?: QueryOptions<DocType> | null
385385
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne'>;
386386
findOne(
387-
filter?: FilterQuery<DocType>,
388-
projection?: ProjectionType<DocType> | null
387+
filter?: FilterQuery<RawDocType>,
388+
projection?: ProjectionType<RawDocType> | null
389389
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne'>;
390390
findOne(
391-
filter?: FilterQuery<DocType>
392-
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne'>;
391+
filter?: FilterQuery<RawDocType>
392+
): QueryWithHelpers<DocType | null, RawDocType, THelpers, RawDocType, 'findOne'>;
393393

394394
/** Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion. */
395395
findOneAndDelete(
396-
filter?: FilterQuery<DocType>,
396+
filter?: FilterQuery<RawDocType>,
397397
options?: QueryOptions<DocType> | null
398398
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndDelete'>;
399399

400400
/** Creates a `findOneAndRemove` query: atomically finds the given document and deletes it. */
401401
findOneAndRemove(
402-
filter?: FilterQuery<DocType>,
402+
filter?: FilterQuery<RawDocType>,
403403
options?: QueryOptions<DocType> | null
404404
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndRemove'>;
405405

406406
/** Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`. */
407407
findOneAndUpdate(
408-
filter: FilterQuery<DocType>,
409-
update: UpdateQuery<DocType>,
408+
filter: FilterQuery<RawDocType>,
409+
update: UpdateQuery<RawDocType>,
410410
options: QueryOptions<DocType> & { rawResult: true }
411411
): QueryWithHelpers<ModifyResult<DocType>, DocType, THelpers, RawDocType, 'findOneAndUpdate'>;
412412
findOneAndUpdate(
413-
filter: FilterQuery<DocType>,
414-
update: UpdateQuery<DocType>,
413+
filter: FilterQuery<RawDocType>,
414+
update: UpdateQuery<RawDocType>,
415415
options: QueryOptions<DocType> & { upsert: true } & ReturnsNewDoc
416416
): QueryWithHelpers<DocType, DocType, THelpers, RawDocType, 'findOneAndUpdate'>;
417417
findOneAndUpdate(
418-
filter?: FilterQuery<DocType>,
419-
update?: UpdateQuery<DocType>,
418+
filter?: FilterQuery<RawDocType>,
419+
update?: UpdateQuery<RawDocType>,
420420
options?: QueryOptions<DocType> | null
421421
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndUpdate'>;
422422

423423
/** Declares the query a findById operation. When executed, returns the document with the given `_id`. */
424424
findById(
425425
id: mongodb.ObjectId | any,
426-
projection?: ProjectionType<DocType> | null,
426+
projection?: ProjectionType<RawDocType> | null,
427427
options?: QueryOptions<DocType> | null
428428
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne'>;
429429
findById(
430430
id: mongodb.ObjectId | any,
431-
projection?: ProjectionType<DocType> | null
431+
projection?: ProjectionType<RawDocType> | null
432432
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne'>;
433433
findById(
434434
id: mongodb.ObjectId | any
@@ -443,22 +443,22 @@ declare module 'mongoose' {
443443
/** Creates a `findOneAndUpdate` query, filtering by the given `_id`. */
444444
findByIdAndUpdate(
445445
id: mongodb.ObjectId | any,
446-
update: UpdateQuery<DocType>,
446+
update: UpdateQuery<RawDocType>,
447447
options: QueryOptions<DocType> & { rawResult: true }
448448
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'findOneAndUpdate'>;
449449
findByIdAndUpdate(
450450
id: mongodb.ObjectId | any,
451-
update: UpdateQuery<DocType>,
451+
update: UpdateQuery<RawDocType>,
452452
options: QueryOptions<DocType> & { upsert: true } & ReturnsNewDoc
453453
): QueryWithHelpers<DocType, DocType, THelpers, RawDocType, 'findOneAndUpdate'>;
454454
findByIdAndUpdate(
455455
id?: mongodb.ObjectId | any,
456-
update?: UpdateQuery<DocType>,
456+
update?: UpdateQuery<RawDocType>,
457457
options?: QueryOptions<DocType> | null
458458
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndUpdate'>;
459459
findByIdAndUpdate(
460460
id: mongodb.ObjectId | any,
461-
update: UpdateQuery<DocType>
461+
update: UpdateQuery<RawDocType>
462462
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndUpdate'>;
463463

464464
/** Specifies a `$geometry` condition */
@@ -472,7 +472,7 @@ declare module 'mongoose' {
472472
get(path: string): any;
473473

474474
/** Returns the current query filter (also known as conditions) as a POJO. */
475-
getFilter(): FilterQuery<DocType>;
475+
getFilter(): FilterQuery<RawDocType>;
476476

477477
/** Gets query options. */
478478
getOptions(): QueryOptions<DocType>;
@@ -481,7 +481,7 @@ declare module 'mongoose' {
481481
getPopulatedPaths(): Array<string>;
482482

483483
/** Returns the current query filter. Equivalent to `getFilter()`. */
484-
getQuery(): FilterQuery<DocType>;
484+
getQuery(): FilterQuery<RawDocType>;
485485

486486
/** Returns the current update operations as a JSON object. */
487487
getUpdate(): UpdateQuery<DocType> | UpdateWithAggregationPipeline | null;
@@ -551,7 +551,7 @@ declare module 'mongoose' {
551551
maxTimeMS(ms: number): this;
552552

553553
/** Merges another Query or conditions object into this one. */
554-
merge(source: Query<any, any> | FilterQuery<DocType>): this;
554+
merge(source: Query<any, any> | FilterQuery<RawDocType>): this;
555555

556556
/** Specifies a `$mod` condition, filters documents for documents whose `path` property is a number that is equal to `remainder` modulo `divisor`. */
557557
mod<K = string>(path: K, val: number): this;
@@ -579,10 +579,10 @@ declare module 'mongoose' {
579579
nin(val: Array<any>): this;
580580

581581
/** Specifies arguments for an `$nor` condition. */
582-
nor(array: Array<FilterQuery<DocType>>): this;
582+
nor(array: Array<FilterQuery<RawDocType>>): this;
583583

584584
/** Specifies arguments for an `$or` condition. */
585-
or(array: Array<FilterQuery<DocType>>): this;
585+
or(array: Array<FilterQuery<RawDocType>>): this;
586586

587587
/**
588588
* Make this query throw an error if no documents match the given `filter`.
@@ -639,7 +639,7 @@ declare module 'mongoose' {
639639
* not accept any [atomic](https://www.mongodb.com/docs/manual/tutorial/model-data-for-atomic-operations/#pattern) operators (`$set`, etc.)
640640
*/
641641
replaceOne(
642-
filter?: FilterQuery<DocType>,
642+
filter?: FilterQuery<RawDocType>,
643643
replacement?: DocType | AnyObject,
644644
options?: QueryOptions<DocType> | null
645645
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'replaceOne'>;
@@ -698,9 +698,9 @@ declare module 'mongoose' {
698698
setOptions(options: QueryOptions<DocType>, overwrite?: boolean): this;
699699

700700
/** Sets the query conditions to the provided JSON object. */
701-
setQuery(val: FilterQuery<DocType> | null): void;
701+
setQuery(val: FilterQuery<RawDocType> | null): void;
702702

703-
setUpdate(update: UpdateQuery<DocType> | UpdateWithAggregationPipeline): void;
703+
setUpdate(update: UpdateQuery<RawDocType> | UpdateWithAggregationPipeline): void;
704704

705705
/** Specifies an `$size` query condition. When called with one argument, the most recent path passed to `where()` is used. */
706706
size<K = string>(path: K, val: number): this;
@@ -738,8 +738,8 @@ declare module 'mongoose' {
738738
* the `multi` option.
739739
*/
740740
updateMany(
741-
filter?: FilterQuery<DocType>,
742-
update?: UpdateQuery<DocType> | UpdateWithAggregationPipeline,
741+
filter?: FilterQuery<RawDocType>,
742+
update?: UpdateQuery<RawDocType> | UpdateWithAggregationPipeline,
743743
options?: QueryOptions<DocType> | null
744744
): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateMany'>;
745745

@@ -748,8 +748,8 @@ declare module 'mongoose' {
748748
* `update()`, except it does not support the `multi` or `overwrite` options.
749749
*/
750750
updateOne(
751-
filter?: FilterQuery<DocType>,
752-
update?: UpdateQuery<DocType> | UpdateWithAggregationPipeline,
751+
filter?: FilterQuery<RawDocType>,
752+
update?: UpdateQuery<RawDocType> | UpdateWithAggregationPipeline,
753753
options?: QueryOptions<DocType> | null
754754
): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateOne'>;
755755

0 commit comments

Comments
 (0)