mongodb - How do I formulate find() based on multiple _ids? -
i trying retrieve 2 objects based on 2 object _ids.
as demonstrated in code below, session.get(); function retrieves 2 _id, use in query.
var selectedid = session.get('selecteditemidset'); selectedid = selectedid.tostring(); selectedid = selectedid.split(","); alert(selectedid);
the alert above pops out 2 _ids : lzjka8s3wynwhakze, ikrbcdutthrwkecuv
console.log("selectedid is: ",...selectedid);
the above console() function yeilds:
selectedid is: lzjka8s3wynwhakze ikrbcdutthrwkecuv
buylist.find({_id:{ "$in": selectedid} }).fetch();
the query above returns 1 object, namely object _id: "lzjka8s3wynwhakze" , not 2 objects expected results.
just clarify, expected result should 2 objects _ids: lzjka8s3wynwhakze, ikrbcdutthrwkecuv
kindly point out doing wrong here?
Comments
Post a Comment