據我所知道的,.then
功能在技術上是過時的貓鼬 - 你想用的你自己實施的承諾。
那說,看起來像貓鼬一直使用mpromise,因爲它的承諾的實施,以及.then
功能實現here:
Promise.prototype.then = function (onFulfill, onReject) {
var newPromise = new Promise;
if ('function' == typeof onFulfill) {
this.onFulfill(handler(newPromise, onFulfill));
} else {
this.onFulfill(newPromise.fulfill.bind(newPromise));
}
if ('function' == typeof onReject) {
this.onReject(handler(newPromise, onReject));
} else {
this.onReject(newPromise.reject.bind(newPromise));
}
return newPromise;
};
.then
剛剛鏈的新承諾,先前承諾的執行。實際上,你有兩個承諾,一個接一個地執行。
你使用庫來查詢你的數據庫?我不記得'.findOne'返回一個承諾。 –
@DanielB,Mongoose – user7361048