diff --git a/src/routes/word/word.model.js b/src/routes/word/word.model.js index 3e9d870..a208ea3 100644 --- a/src/routes/word/word.model.js +++ b/src/routes/word/word.model.js @@ -12,6 +12,8 @@ const wordSchema = new mongoose.Schema( { timestamps: true } ); +wordSchema.index({ word: 1 }); + wordSchema.pre(/^findOne/, async function (next) { await this.model.updateOne(this.getQuery(), { $inc: { freq: 1 } }); next();