Skip to content

Commit

Permalink
docs(model): add blog post link and example to syncIndexes() docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Sep 13, 2018
1 parent 2d928b4 commit 25c305d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/model.js
Expand Up @@ -1027,6 +1027,17 @@ Model.init = function init(callback) {
* 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.
*
* See the [introductory blog post](http://thecodebarbarian.com/whats-new-in-mongoose-5-2-syncindexes)
* for more information.
*
* ####Example:
*
* const schema = new Schema({ name: { type: String, unique: true } });
* const Customer = mongoose.model('Customer', schema);
* await Customer.createIndex({ age: 1 }); // Index is not in schema
* // Will drop the 'age' index and create an index on `name`
* await Customer.syncIndexes();
*
* @param {Object} [options] options to pass to `ensureIndexes()`
* @param {Function} [callback] optional callback
Expand Down

0 comments on commit 25c305d

Please sign in to comment.