Skip to content

Commit f6bb305

Browse files
committed
Create individual indexes for related resources.
We were creating a compound index for all related resources of a resource, but actually what we wanted were individual indexes for each one: fix this state of affairs.
1 parent fbeed58 commit f6bb305

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lib/mongoHandler.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,11 @@ MongoStore._unknownError = function(err) {
133133
MongoStore.prototype._createIndexesForRelationships = function(collection, relationshipAttributeNames) {
134134
if (!Array.isArray(relationshipAttributeNames) || !relationshipAttributeNames.length) return;
135135

136-
var index = relationshipAttributeNames.reduce(function(partialIndex, name) {
137-
if (name) {
138-
partialIndex[name + ".id"] = 1;
139-
}
140-
return partialIndex;
141-
}, {});
142-
if (Object.keys(index).length) {
143-
collection.createIndex(index);
144-
}
136+
relationshipAttributeNames.forEach(function(name) {
137+
var keys = { };
138+
keys[name + ".id"] = 1;
139+
collection.createIndex(keys);
140+
});
145141
};
146142

147143
MongoStore.prototype._applySort = function(request, cursor) {

0 commit comments

Comments
 (0)