File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -147,19 +147,20 @@ MongoStore._unknownError = function(err) {
147147 } ;
148148} ;
149149
150-
151150MongoStore . prototype . _createIndexesForRelationships = function ( collection , relationshipAttributeNames ) {
151+ if ( ! ( relationshipAttributeNames instanceof Array ) || ! relationshipAttributeNames . length ) { return }
152+
152153 var index = relationshipAttributeNames . reduce ( function ( partialIndex , name ) {
153- partialIndex [ name + ".id" ] = 1 ;
154+ if ( name ) {
155+ partialIndex . push ( [ name + ".id" , 1 ] ) ;
156+ }
157+
154158 return partialIndex ;
155- } , { } ) ;
159+ } , [ ] ) ;
156160
157- if ( Object . keys ( index ) . length ) {
158- collection . createIndex ( index ) ;
159- }
161+ collection . ensureIndex ( index ) ;
160162} ;
161163
162-
163164MongoStore . prototype . _applySort = function ( request , cursor ) {
164165 if ( ! request . params . sort ) return cursor ;
165166
You can’t perform that action at this time.
0 commit comments