Let's say there is a data structure containing objects like
{
name : 'ernie',
likes : [
{
what : 'rubber duckie',
howmuch : 5
},
{
what : 'bert',
howmuch : 3
}]
}
and
{
name : 'cookie monster',
likes : [
{
what : 'cookies',
howmuch : 100
}]
}
If the 0th element of ernie's likes-array should have its howmuch-value incremented, say, by 1, is there a MongoDB command to do this? The JavaScript-equivalent would be ernie.likes[0].howmuch++.
Specifically, can you access the elements of an array by index number?