You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey there. first off: awesome stuff you did with mingo. However I encountered a bug while querying a nested array using $all and $elemMatch. I setup a testcase to illustrate the issue:
test("elemMatch on nested elements",function(){vartestobject=[{user: {username: 'User1',projects: [{name: "Project 1",rating: {complexity: 6}},{name: "Project 2",rating: {complexity: 2}}]}},{user: {username: 'User2',projects: [{name: "Project 1",rating: {complexity: 6}},{name: "Project 2",rating: {complexity: 8}}]}}],query={'user.projects': {"$all": [{"$elemMatch": {'rating.complexity': {'$gt' : 6}}}]}};// It should return one user objectok(Mingo.compile(query).test(testobject));});
Hi Steffen, am glad you find mingo useful and thanks for the report. I have resolved this bug and made a few corrections to your test case. The test function works per object instead of a collection. The find function is more appropriate instead.
vardata=[{user: {username: 'User1',projects: [{name: "Project 1",rating: {complexity: 6}},{name: "Project 2",rating: {complexity: 2}}]}},{user: {username: 'User2',projects: [{name: "Project 1",rating: {complexity: 6}},{name: "Project 2",rating: {complexity: 8}}]}}];varquery={'user.projects': {"$all": [{"$elemMatch": {'rating.complexity': {'$gt' : 6}}}]}};// It should return one user objectvarresult=Mingo.find(data,query).count();equal(1,result,"can match using $all with $elemMatch on nested elements");
Hey there. first off: awesome stuff you did with mingo. However I encountered a bug while querying a nested array using $all and $elemMatch. I setup a testcase to illustrate the issue:
Expected behavior: http://docs.mongodb.org/manual/reference/operator/query/all/#use-all-with-elemmatch
The text was updated successfully, but these errors were encountered: