I have written a function like this
function create(data, res){
var history= new historyData({
owner: data
});
historyData.save(function(err, historyData) {
//To identify the error
if (err) {
console.log(err);
}
//If no error pass the team details to databsae
else {
return historyData.id;
}
});
}
and I'm trying to get the return value like this
var history = create("saddsa", res);
but it gives undefined error
I want to get the id of the created collection and pass it to another function?