'Cannot perform a non-multi update on a time-series collection

Hi I am using newly Timeseries mongodb collection. My mongodb version is 5.0.6. I am following this tutorial. I create a collection like this.

   db.createCollection("ticker", {
     timeseries: {
        timeField: "time",
        metaField: "metadata",
    },
});

I inserted the sample document like this.

db.ticker.insertOne({
 time: ISODate("20210101T01:00:00"),
 symbol: "BTC-USD",
 price: 34114.1145,
 metadata: { a: ""}
});

When I am trying to update metadata field it gives above error. As mentioned here is limitation you can only update metaField but still it is giving above error. Here is the update code

db.ticker.update({ "metadata.a": "a" }, { $set: { "metadata.d": "a" } })

write failed with error: {
    "nMatched" : 0,
    "nUpserted" : 0,
    "nModified" : 0,
    "writeError" : {
        "code" : 72,
        "errmsg" : "Cannot perform a non-multi update on a time-series collection"
    }
}

Need help what I am doing wrong.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source