[英]Mongoose setOnInsert : use computed property inside the query
當我在Mongoose控制台中使用setOnInsert時,返回我無法在setOnInsert內部使用計算屬性,如以下消息所示:
語法錯誤:意外令牌[
findOneAndUpdate:{
"filter": hour[daySlot].time.timePlot,
"$setOnInsert": { hour[daySlot][time]: update }, // fails to use computed properties
upsert: true
}
我的參數是動態的,我需要使用計算的屬性。
任何提示都會很棒,謝謝。
您需要在hour[daySlot][time]
左右使用方括號
findOneAndUpdate:{
"filter": hour[daySlot].time.timePlot,
"$setOnInsert": { [hour[daySlot][time]]: update }, // fails to use computed properties
upsert: true
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.