diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 42e3ca3742..548852405b 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -1417,6 +1417,9 @@ declare module "mongoose" { circle(area: Object): this; circle(path: string, area: Object): this; + /** Adds a collation to this op (MongoDB 3.4 and up) */ + collation(value: CollationOptions): this; + /** Specifies the comment option. Cannot be used with distinct() */ comment(val: string): this; @@ -1817,6 +1820,17 @@ declare module "mongoose" { context?: string; } + interface CollationOptions { + locale?: string; + caseLevel?: boolean; + caseFirst?: string; + strength?: number; + numericOrdering?: boolean; + alternate?: string; + maxVariable?: string; + backwards?: boolean; + } + namespace Schema { namespace Types { /* @@ -2089,6 +2103,9 @@ declare module "mongoose" { */ append(...ops: Object[]): this; + /** Adds a collation. */ + collation(options: CollationOptions): this; + /** * Sets the cursor option option for the aggregation query (ignored for < 2.6.0). * Note the different syntax below: .exec() returns a cursor object, and no callback diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index 7e3f815421..c6de968430 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -660,6 +660,7 @@ query.catch(cb).catch(cb); query.center({}).center({}); query.centerSphere({ center: [50, 50], radius: 10 }).centerSphere('path', {}); query.circle({ center: [50, 50], radius: 10 }).circle('path'); +query.collation({ locale: 'en_US', strength: 1 }); query.comment('comment').comment('comment'); query.where({color: 'black'}).count(function (err, count) { count.toFixed(); @@ -995,6 +996,7 @@ aggregate.addCursorFlag('flag', true).addCursorFlag('', false); aggregate.allowDiskUse(true).allowDiskUse(false, []); aggregate.append({ $project: { field: 1 }}, { $limit: 2 }); aggregate.append([{ $match: { daw: 'Logic Audio X' }} ]); +aggregate.collation({ locale: 'en_US', strength: 1 }); aggregate.cursor({ batchSize: 1000 }).exec().each(cb); aggregate.exec().then(cb).catch(cb); aggregate.explain(cb).then(cb).catch(cb);