I am trying to update an object inside of an array. Here is my structure:
"_id": "ubtQP9EjmxhXS5z98",
"name": "My Data",
"desc": "What songs should I play at my wedding?",
"private": false,
"suggestions": [
{
"name": "Vote 1",
"link": "http://www.website.com/",
"votes": 0
},
{
"name": "Vote 2",
"votes": 0
}
],
"author": "tovd9Win3C3fntgyR",
"createdAt": "2016-01-10T08:36:37.014Z"
I want to update the votes on the first object in "suggestions" by 1. At the moment I have the following code but it does NOT work.
Polls.update("ubtQP9EjmxhXS5z98", {
$inc: {suggestions.$.votes: 1},
});