Problem reading the value of mongo objects

Hi,

i have a collection on mongo that stores facebook ids and their matching meteor ids.

each line looks like that

{ "_id" : "v79gnNvAMcKSm5PcC", "facebookId" : "[id]", "meteorId" : "MwZyjDhkvsedy7yq8" }

when i call on the shell

db.usersMap.find({"facebookId" : "[id]"}, {"meteorId":1, "_id":0});

i get the following response:

{ "meteorId" : "MwZyjDhkvsedy7yq8" }

the problem -
on the server side i want to get ONLY the value of the “meteorId”, but cant. this is the code i worte:

const object = UsersMap.find({"facebookId" : facebookId}, {"meteorId":1, "_id":0});
const meteor_id = object.meteorId;
console.log(meteor_id);

also tried

const object = UsersMap.find({"facebookId" : facebookId}, {"meteorId":1, "_id":0});
console.log(Object.values(meteor_id));

BUT ITS NOT WORKING.

ideas?
thanks :slight_smile:

find returns a cursor, not an object. You could use findOne or find(...).fetch()[0]

1 Like

right, I forgot about that.
thank you so much!

1 Like