Skip to content

Commit

Permalink
♻️ refactor: word 스키마 단어명 인덱스 설정 Murakano#99
Browse files Browse the repository at this point in the history
  • Loading branch information
jjikky committed Oct 29, 2024
1 parent 91be13b commit c5d783f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/routes/word/word.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c5d783f

Please sign in to comment.