I have this set of data:
[
{
_id: new ObjectId(“6249b1abd4b9d2257d72fedf”),
‘223503056178905088’: {
UID: ‘223503056178905088’,
total: 8845455,
name: ‘Cigora /Matze#1368’,
rank: [Array],
joined: 1649019586262
},
‘236840013843791874’: {
UID: ‘236840013843791874’,
total: 6676639,
name: ‘viciousDom#2027’,
rank: [Array],
joined: 1648917920576
},
‘505732249715736576’: {
UID: ‘505732249715736576’,
total: 4541,
name: ‘Mulon#5667’,
rank: [Array],
joined: 1541018286580
}
}
]
In the “rank” the array is made of [“1234”, “”]
So how can I update rank[1]?
Also the main object key (the number) is queried by a variable, which in JS I’d be using bracket notation. But it doesnt seem to work in mongo.
Let userid = ‘505732249715736576’
[userid]rank <— shows error
In the documents it says to use dot notation wrapped in quotes. This still creates a key, doesnt access the properties.
‘[userid]rank’