I'm trying to push values to an array at a specific index of an array using the following code:
Freezer.update(conditions, {$push: {shelves[shelfindex] : {"rackname": rackname, "columns": columns, "rows": rows, "spaces" : []}}}, function (err, doc){
console.log(doc);
})
where shelfindex is the index of the shelf at hand, that I find with a preceeding for loop (code not shown).
It's not working (the program won't even start up). I get the following error:
SyntaxError: Unexpected token [
My shelves array is set up like:
[{"racks":[],"shelfname":"Shelf 1"},{"racks":[],"shelfname":"Shelf 2"},{"racks":[],"shelfname":"Shelf 3"}]
So for instance if I was trying to push rack data to "Shelf 1" I am attempting to push it to:
shelves[0].racks
Any ideas for a solution?