我怎樣才能解決result。目前,我的代碼沒有解決result,控制臺記錄 "Successfully found document: [Object物件]"。這就是MongoDB。我希望得到任何幫助。
await dbo. collection("a").findOne({ item: "journal" }, {_id:0})
.then(result => {
async function rs(){
await result
}
rs()
if(結果) {
console.log(`Successfully found document: ${result}.`)。)
} else {
console.log("No document matching the provided query." )。
}
return result。
})
.catch(err => console. error(`Failed to find document: ${err}`))。)
這是我的MongoDB檔案:
_id: 61462a7bf3c0be993bcfdc3e
item:"journal"/span>
數量:25。
size:Object
status:"A"。
uj5u.com熱心網友回復:
試做:
const results = await dbo. collection("a").findOne({ item。"journal" })
if(!!results) {
console.log(`Successfully found document: ${JSON.stringify(result)}.`)。)
}
else {
console.log("No document matching the provided query;)
}
//其余的邏輯。
請確保你所執行的上述代碼被包裹在一個異步函式中。
今后有任何問題,請隨時提出。 謝謝 :)
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/324691.html
標籤:
