Tuesday 11 April 2017

Get error when using multiple select of different object in mongoose

I create a query with find and $or, and I want to select multiple fields but not in the same nested object, this is my query I tried two codes, and i have two exceptions

first code

 item.find({})
                    .where({$or:[{'form.f_type': 'file'}, {'licence.c_type': 'file'}]})
                    .select({'form.$':1})
                    .select({'licence.$':1}) //line deleted in **second code
                   .exec(function(err2, posts) {
                        //   console.log(posts);
                        if (err2) {

                            callback(err2) ;

                        } else {

                            callback(posts) ;

                        }
                    });

First exception

BadValue : "Cannot specify more than one positional proj. per query."

Second code I delete this line

.select({'licence.$':1})

i Have this exception :

OperationFailed : "Executor error during find command: BadValue: positional operator (oi_formValue.$) requires corresponding field in query specifier"

Is there a solution to select my objects form and licence ?



via user2285831

No comments:

Post a Comment