0

I would like to get one field from the selected documents but I want all of the values to be in a simple array.

users.find({}, ['regid'], function(err, docs){
    //console.log(docs);
});

should return:

['reg1','reg2',...]

Thank you

1 Answer 1

1

You can do:

users.find({}, {'regid' : 1}).toArray(function(err, docs){
    //console.log(docs);
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.