If I console.log the output from count+1, I get a correct number value. If I output the value of note.note_id, I get undefined. Why is this?
I have tried setting value to a predefined one inside the function.
note.note_id = db.notes.count(function(err, count) {
return count + 1;
});
Hard to answer without knowing what
db.notesis but it seems to be something accessing a database. This means it’s most likely asynchronous which meansa that thecount()method will never return a value but you need to do whatever you want to do with the result inside the callback.