0
我將returnNewDocument修復爲true,但仍然有舊文檔,我該如何解決這個問題?更新並返回新文檔mongodb angularjs 2打字稿
public updateBestScore(scoreBD: ScoreBD, level: string): Promise<any> {
return client.connect(url)
.then(
// Promesse tenue
(db: any) => db.collection('BEST_SCORES').findOneAndUpdate(
{ "level": level.toLowerCase, "bestScore.username": scoreBD.usernameBD },
{ $set: { "bestScore.$.score": scoreBD.score, "bestScore.$.username": scoreBD.usernamePlayer} },
{ returnNewDocument : true }
)
.then(
(res: any) => {
db.close();
console.log("resultat : ", res);
if (res.lastErrorObject.updatedExisting === true) {
console.log("resultat apres findOneAndUpdate : ", res.value.bestScore);
}
}),
// Promesse rompue
(err: any) => { throw "erreur"; });
}
添加一些關於您所期望的和您遇到的問題的描述 –
我想更新我的集合並返回新的更新集合。但該方法仍舊在更新 –
添加註釋之前返回舊集合的問題 –