diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index df91675e15..9a29c8d347 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -15,6 +15,7 @@ // Norman Perrin // Dan Manastireanu // stablio +// Emmanuel Gautier // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -1897,13 +1898,13 @@ declare module "mongoose" { * is an Array. See the examples. */ geometry(object: { type: string, coordinates: any[] }): this; - + /** * Returns the current query options as a JSON object. * @returns current query options */ getOptions(): any; - + /** * Returns the current query conditions as a JSON object. * @returns current query conditions @@ -2905,6 +2906,29 @@ declare module "mongoose" { distinct(field: string, conditions: any, callback?: (err: any, res: any[]) => void): Query & QueryHelpers; + /** + * Makes the indexes in MongoDB match the indexes defined in this model's + * schema. This function will drop any indexes that are not defined in + * the model's schema except the `_id` index, and build any indexes that + * are in your schema but not in MongoDB. + * @param options options to pass to `ensureIndexes()` + * @param callback optional callback + * @return Returns `undefined` if callback is specified, returns a promise if no callback. + */ + syncIndexes(options: object, callback?: (err: any) => void): void; + syncIndexes(options: object): Promise; + + /** + * Lists the indexes currently defined in MongoDB. This may or may not be + * the same as the indexes defined in your schema depending on whether you + * use the [`autoIndex` option](/docs/guide.html#autoIndex) and if you + * build indexes manually. + * @param cb optional callback + * @return Returns `undefined` if callback is specified, returns a promise if no callback. + */ + listIndexes(callback: (err: any) => void): void; + listIndexes(): Promise; + /** * Sends ensureIndex commands to mongo for each index declared in the schema. * @param options internal options diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index 8f5914d9dd..865b45a64d 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -1636,6 +1636,10 @@ MongoModel.create([{ type: 'jelly bean' }, { MongoModel.distinct('url', { clicks: {$gt: 100}}, function (err, result) { }); MongoModel.distinct('url').exec(cb); +MongoModel.syncIndexes({}); +MongoModel.syncIndexes({}, cb); +MongoModel.listIndexes(); +MongoModel.listIndexes(cb); MongoModel.ensureIndexes({}, cb); MongoModel.find({ name: 'john', age: { $gte: 18 }}); MongoModel.find({ name: 'john', age: { $gte: 18 }}, function (err, docs) { diff --git a/types/mongoose/v4/index.d.ts b/types/mongoose/v4/index.d.ts index 8f8029a2e1..24aeb75050 100644 --- a/types/mongoose/v4/index.d.ts +++ b/types/mongoose/v4/index.d.ts @@ -3,7 +3,6 @@ // Definitions by: simonxca // horiuchi // lukasz-zak -// Emmanuel Gautier // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -2502,29 +2501,6 @@ declare module "mongoose" { distinct(field: string, conditions: any, callback?: (err: any, res: any[]) => void): Query; - /** - * Makes the indexes in MongoDB match the indexes defined in this model's - * schema. This function will drop any indexes that are not defined in - * the model's schema except the `_id` index, and build any indexes that - * are in your schema but not in MongoDB. - * @param options options to pass to `ensureIndexes()` - * @param callback optional callback - * @return Returns `undefined` if callback is specified, returns a promise if no callback. - */ - syncIndexes(options: object, callback?: (err: any) => void): void; - syncIndexes(options: object): Promise; - - /** - * Lists the indexes currently defined in MongoDB. This may or may not be - * the same as the indexes defined in your schema depending on whether you - * use the [`autoIndex` option](/docs/guide.html#autoIndex) and if you - * build indexes manually. - * @param cb optional callback - * @return Returns `undefined` if callback is specified, returns a promise if no callback. - */ - listIndexes(callback: (err: any) => void): void; - listIndexes(): Promise; - /** * Sends ensureIndex commands to mongo for each index declared in the schema. * @param options internal options diff --git a/types/mongoose/v4/mongoose-tests.ts b/types/mongoose/v4/mongoose-tests.ts index 95770c0305..633d3438a8 100644 --- a/types/mongoose/v4/mongoose-tests.ts +++ b/types/mongoose/v4/mongoose-tests.ts @@ -1361,10 +1361,6 @@ MongoModel.create([{ type: 'jelly bean' }, { MongoModel.distinct('url', { clicks: {$gt: 100}}, function (err, result) { }); MongoModel.distinct('url').exec(cb); -MongoModel.syncIndexes({}); -MongoModel.syncIndexes({}, cb); -MongoModel.listIndexes(); -MongoModel.listIndexes(cb); MongoModel.ensureIndexes({}, cb); MongoModel.find({ name: 'john', age: { $gte: 18 }}); MongoModel.find({ name: 'john', age: { $gte: 18 }}, function (err, docs) {