mongoose: move syncIndexes and listIndexes into the right version

This commit is contained in:
Emmanuel Gautier
2019-01-21 21:37:09 +01:00
parent ca809fa16f
commit accf57f979
4 changed files with 30 additions and 30 deletions
+26 -2
View File
@@ -15,6 +15,7 @@
// Norman Perrin <https://github.com/NormanPerrin>
// Dan Manastireanu <https://github.com/danmana>
// stablio <https://github.com/stablio>
// Emmanuel Gautier <https://github.com/emmanuelgautier>
// 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<any[]> & 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<void>;
/**
* 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<void>;
/**
* Sends ensureIndex commands to mongo for each index declared in the schema.
* @param options internal options
+4
View File
@@ -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) {
-24
View File
@@ -3,7 +3,6 @@
// Definitions by: simonxca <https://github.com/simonxca>
// horiuchi <https://github.com/horiuchi>
// lukasz-zak <https://github.com/lukasz-zak>
// Emmanuel Gautier <https://github.com/emmanuelgautier>
// 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<any[]>;
/**
* 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<void>;
/**
* 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<void>;
/**
* Sends ensureIndex commands to mongo for each index declared in the schema.
* @param options internal options
-4
View File
@@ -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) {