私が知る限り、Mongooses schema.save()
メソッドは非同期です。 schema.save()
メソッドの前に外部関数を実行することが可能ですか?schema.save()
は、外部関数の処理が完了するまで呼び出されません。schema.saveメソッドの前に外部関数を実行
//External function
incrementTotal(req,res);
newSurvey.save(function (err, data) {
if(err) {
sendJsonResponse(res, 400, err)
} else{
console.log("3")
sendJsonResponse(res, 200, data);
}
});
問題:
incrementTotal
前newSurvey.save
実行が処理を終えることができる特定の状況があります。この問題を解決するにはどうすればよいですか?
コールバックを使用してください: – xShirase