File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -147,16 +147,20 @@ MongoStore._unknownError = function(err) {
147147 } ;
148148} ;
149149
150-
151150MongoStore . prototype . _createIndexesForRelationships = function ( collection , relationshipAttributeNames ) {
151+ if ( ! Array . isArray ( relationshipAttributeNames ) || ! relationshipAttributeNames . length ) return ;
152+
152153 var index = relationshipAttributeNames . reduce ( function ( partialIndex , name ) {
153- partialIndex [ name + ".id" ] = 1 ;
154+ if ( name ) {
155+ partialIndex [ name + ".id" ] = 1 ;
156+ }
154157 return partialIndex ;
155158 } , { } ) ;
156- collection . createIndex ( index ) ;
159+ if ( Object . keys ( index ) . length ) {
160+ collection . createIndex ( index ) ;
161+ }
157162} ;
158163
159-
160164MongoStore . prototype . _applySort = function ( request , cursor ) {
161165 if ( ! request . params . sort ) return cursor ;
162166
You can’t perform that action at this time.
0 commit comments