diff --git a/models/action.js b/models/action.js index 5e2dc1128..f3414f3ea 100644 --- a/models/action.js +++ b/models/action.js @@ -37,6 +37,17 @@ const ActionSchema = new Schema( } ); +// Create an index on the `item_id` field so that queries looking for +// actions based on the item id can resolve faster. +ActionSchema.index( + { + item_id: 1, + }, + { + background: true, + } +); + const Action = mongoose.model('Action', ActionSchema); module.exports = Action;