mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 20:21:46 +00:00
mongoose: add syncIndexes and listIndexes missingModel methods
This commit is contained in:
Vendored
+28
-2
@@ -1,6 +1,9 @@
|
||||
// Type definitions for Mongoose 4.7.1
|
||||
// Type definitions for Mongoose 4.7.2
|
||||
// Project: http://mongoosejs.com/
|
||||
// Definitions by: simonxca <https://github.com/simonxca>, horiuchi <https://github.com/horiuchi>, lukasz-zak <https://github.com/lukasz-zak>
|
||||
// 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
|
||||
|
||||
@@ -2499,6 +2502,29 @@ 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
|
||||
|
||||
@@ -1361,6 +1361,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) {
|
||||
|
||||
Reference in New Issue
Block a user