我想在 findOneAndUpdate 中使用 _id 物件作為過濾器:
{
"_id": {
"playerId": "189583",
"tournamentId": "197831"
},
"playerName": "Afiridi",
"score": [],
"__v": 0
}
我試過這個,但沒有用:
await Scorecard.findOneAndUpdate(
{
_id: {
playerId: playerId,
tournamentId: tournamentId
}
},
{
$addToSet: {
"score": {
_id: matchID
}
}
}
);
//playerId and tournamentId are coming from above code, not listed
我使用貓鼬,但任何形式的幫助表示贊賞。
uj5u.com熱心網友回復:
嘗試點符號語法:
await Scorecard.findOneAndUpdate(
{
"_id.playerId": playerId,
"_id.tournamentId": tournamentId
},
{
$addToSet: {
"score": {
_id: matchID
}
}
}
);
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/350148.html
標籤:节点.js MongoDB 猫鼬 mongodb-查询
