> db.foo.insert(
{"items":[null,null,null,null]})
> db.foo.find()
> db.foo.update({_id:ObjectId("4bac322669b89c9179dc9976")},{$set:{"items.0":
{itemId:1,amount:9000}}})
> db.foo.find()
{ "_id" : ObjectId("4bac322669b89c9179dc9976"), "items" :
[
, null, null, null ] }
> db.foo.update({_id:ObjectId("4bac322669b89c9179dc9976")},{$inc:
,$set:{"items.1":
{itemId:1,amount:1}}})
> db.foo.find()
{ "_id" : ObjectId("4bac322669b89c9179dc9976"), "items" : [
,
,
,
null,
null
] }
>
I hope that the result should be
{ "_id" : ObjectId("4bac322669b89c9179dc9976"), "items" : [
,
,
null,
null,
null
] }