1// Playground: https://mongoplayground.net/p/-TgGWwBd5l-
2db.collection.update({
3 "_id": "password"
4},
5{
6 "$inc": {
7 "waitlist.$[].queue_place": -1
8 }
9})
10
11// Database
12/*
13[
14 {
15 "_id": "password",
16 "waitlist": [
17 {
18 "_id": "adasd",
19 "queue_place": 123
20 },
21 {
22 "_id": "ada43sd",
23 "queue_place": 2
24 }
25 ]
26 }
27]
28*/
1Person.findOneAndUpdate({_id: id},
2{
3 "$set": {[`items.$[outer].${propertyName}`]: value}
4},
5{
6 "arrayFilters": [{ "outer.id": itemId }]
7},
8function(err, response) {
9 ...
10})
11