Reputation: 12076
When I'm using setOnInsert in Mongoose console returns me that I can't use computed property inside setOnInsert as following message illustrate it:
SyntaxError: Unexpected token [
findOneAndUpdate:{
"filter": hour[daySlot].time.timePlot,
"$setOnInsert": { hour[daySlot][time]: update }, // fails to use computed properties
upsert: true
}
My parameter are dynamics and I need to use computed properties.
Any hint would be great, thanks.
Upvotes: 0
Views: 212
Reputation: 5212
You need to use square brackets around hour[daySlot][time]
findOneAndUpdate:{
"filter": hour[daySlot].time.timePlot,
"$setOnInsert": { [hour[daySlot][time]]: update }, // fails to use computed properties
upsert: true
}
Upvotes: 2