Added index for item_id on Actions.

This commit is contained in:
Wyatt Johnson
2018-01-04 14:14:27 -07:00
parent 1125351cd1
commit 66f068359f
+10 -2
View File
@@ -21,8 +21,8 @@ const ActionSchema = new Schema({
item_id: String,
user_id: String,
// The element that summaries will additionally group on in addtion to their action_type, item_type, and
// item_id.
// The element that summaries will additionally group on in addition to their
// action_type, item_type, and item_id.
group_id: String,
// Additional metadata stored on the field.
@@ -34,6 +34,14 @@ 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;