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

$in operator not working properly #24

Open
waqas-ali opened this issue Dec 7, 2017 · 5 comments
Open

$in operator not working properly #24

waqas-ali opened this issue Dec 7, 2017 · 5 comments

Comments

@waqas-ali
Copy link

waqas-ali commented Dec 7, 2017

The $in operator always fetch one record.

I have very simple database structure as shown below

zangodb

I am trying to fetch all those records which have name field value 'Bill' or 'Don' I am using $in operator but it always return only one row. Below is the code that I am using

let db = new zango.Db('customer_db', { customers: ['snn'] });
let people = db.collection('customers');

people.find({
	name: { $in: ["Don","Bil"]}
}).forEach(doc => console.log('doc:', doc));

and the output of above code is

output

@erikolson186 can you please help me know to resolve above issue?

@erikolson186
Copy link
Owner

I tried your example code with your data, and two documents were outputted.

Perhaps try this code and see what the output is:

people.find({
    name: { $in: ['Don', 'Bil'] }
}).toArray((error, docs) => {
    console.log(error, docs);
});

@waqas-ali
Copy link
Author

@erikolson186 no still getting one object in the array. Surprisingly $nin operator working fine and I am able to fetch multiple rows.

@waqas-ali
Copy link
Author

I have checked it on both chrome and firefox still same issue.

@waqas-ali
Copy link
Author

@erikolson186 one more thing I am using library from this link

<script src="https://unpkg.com/zangodb@latest/dist/zangodb.min.js"></script>

@preetamyadav
Copy link

preetamyadav commented Jan 25, 2018

@waqas-ali I have checked it on chrome Version 63.0.3239.108 (Official Build) (64-bit)
and it's working fine for me.

https://jsbin.com/xirumed/1/edit?js,output

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

3 participants