How to update timeseries collection Data using C#

I am working on the timeseries collection, need to update some of the fields using ObjectId. But getting the exception in updating the document
error: MongoDB.Driver.MongoWriteException: A write operation resulted in an error. WriteError: { Category : “Uncategorized”, Code : 72, Message : “Cannot perform a non-multi update on a time-series collection” }.

A bulk write operation resulted in one or more errors. WriteErrors: [ { Category : “Uncategorized”, Code : 72, Message : “Cannot perform a non-multi update on a time-series collection” } ].
at MongoDB.Driver.MongoCollectionImpl1.BulkWriteAsync(IClientSessionHandle session, IEnumerable1 requests, BulkWriteOptions options, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl1.UsingImplicitSessionAsync[TResult](Func2 funcAsync, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionBase1.ReplaceOneAsync(FilterDefinition1 filter, TDocument replacement, ReplaceOptions options, Func3 bulkWriteAsync) --- End of inner exception stack trace --- at MongoDB.Driver.MongoCollectionBase1.ReplaceOneAsync(FilterDefinition1 filter, TDocument replacement, ReplaceOptions options, Func3 bulkWriteAsync)

My question is do we have any provision to update the timeseries collection?

Hello @Rishabh_soni ,

Welcome to The MongoDB Community Forums!

As the error suggests, update command must not limit the number of documents to be updated. Set multi: true or use the updateMany() method. This is a requirement to run update command in timeseries collection. To learn more about this please visit Updates and Deletes in Time Series Collection .

Regards,
Tarun

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.