Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the expect action when using $in to query on an array #178

Open
ShongSu opened this issue Jun 20, 2019 · 0 comments
Open

What is the expect action when using $in to query on an array #178

ShongSu opened this issue Jun 20, 2019 · 0 comments

Comments

@ShongSu
Copy link

ShongSu commented Jun 20, 2019

Hi,
I have such data in my db:

{ "_id": 1, "name": "aaa", "dp": ['dp1'] }, 
 { "_id": 2, "name": "bbb", "dp": ['dp2'] },
{ "_id": 3, "name": "ccc", "dp": ['dp2','dp1'] },
{ "_id": 4, "name": "ddd", "dp": ['dp1', 'dp2','dp3'] }, 
{ "_id": 5, "name": "eee", "dp": ['dp1','dp3'] },
{ "_id": 6, "name": "fff", "dp": ['dp2','dp3'] }

Here I am supposed to get dp' array contains dp1 or dp2 or both.

This is my query code:

collection.find({ dp: { $in: ['dp1','dp2'] }}).toArray(function(err, documents){
    console.log(documents)
});

When I run this test on Mongo v3.4.16 and v3.6.6, the results are as we expected.

{"_id":1,"name":"aaa","dp":["dp1"]}
{"_id":2,"name":"bbb","dp":["dp2"]}
{"_id":3,"name":"ccc","dp":["dp2","dp1"]}
{"_id":4,"name":"ddd","dp":["dp1","dp2","dp3"]}
{"_id":5,"name":"eee","dp":["dp1","dp3"]}
{"_id":6,"name":"fff","dp":["dp2","dp3"]}

But when I run the same query in Tingo, what I got is

[ { _id: 1, name: 'aaa', dp: [ 'dp1' ] },
  { _id: 2, name: 'bbb', dp: [ 'dp2' ] } ]

I tried on apiLevel both v1.6 and v2.0, they give me same result.

I am not able to find documentation of Mango v1.6 or v2.0 on their official website, so I am not sure if the $in has different functionality in earlier version or it is a bug in Tingo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant