i am new to using easymongo and mongodb.
I have the following code that save a record to a database
var id;
chatRooms.save(chatData).then(function(res){
console.log("save chat", res);
id = res._id;
});
now if i log id to the console i get undefined, but if i log it withing the save function i get the ID.
I know that this is because what is returned is a promise but i don't know what to do with it. All i want is to be able to store the ID of the new record.
Thanks.