Adding and deleting multiple fields in a nested object in mongodb
<p>I have this MongoDB data which I have inserted this way:</p>

<pre><code>db.orders.insert({ _id: ObjectId().str, name: "admin", status: "online",catalog : [
    {
        "objectid" : ObjectId().str,
        "message" : "sold",
        "status" : "open"
    }
]})
</code></pre>

<p>First, I want to add new fields to the catalog object which I am doing like this:</p>

<pre><code>db.orders.update({"_id":"5703b86df3d607cb5fa75ff3"},{$set: {"catalog.0.day": "tuesday"},{"catalog.0.payments": "paypal"}});
</code></pre>

<p>That code fails with this error:</p>

<pre><code>2016-04-05T16:48:41.757+0300 E QUERY    [thread1] SyntaxError: invalid property id @(shell):1:88
</code></pre>

<p>I also want to delete some fields and I am preparing to do so with this code:</p>

<pre><code>db.orders.update({"_id":"5703b86df3d607cb5fa75ff3"},{$unset: {"catalog.0.day": ""},{"catalog.0.payments": ""}});
</code></pre>

<p>Why is the update statement failing and how can I delete the fields I have added?</p>