1

If i try to update capped collection it returns "Capped collections can't be updated". What I came to know is capped collections can't be updated.

I'm newbie, and for my project requirements I have to notify client about any data updates at server and I'm using NodeJS

Is there any way to update capped collection. Thanks in advance :)

UserAT152
  • 15
  • 5

1 Answers1

0

According to the docs ...

Document Size

Changed in version 3.2.

If an update or a replacement operation changes the document size, the operation will fail.

Capped collections are intended for usage patterns such as: 'write once and then read as long as it is available' (or, as the docs put it: "Capped collections are fixed-size collections that support high-throughput operations that insert and retrieve documents based on insertion order") so although updates are supported (as long as they do not change document size) they aren't typically expected on a capped collection.

If you need to update this collection and you cannot be certain that the updates will not change collection size then the collection should not be capped. Perhaps you should reconsider (a) whether the collection should be continue to be a capped colleciotn or (b) why you need to update the collection.

Community
  • 1
  • 1
glytching
  • 44,936
  • 9
  • 114
  • 120
  • @UserAT152 so you expect updates to this collection. That being the case, you can only cap this collection if you are **certain** that the updates will not change collection size (by "size" I mean storage size not the number of documents). Since you are seeing write failures with "Capped collections can't be updated" it must be the case that your updates are changing the storage size of the collection therefore a capped collection is not suitable for your usage. – glytching Aug 30 '17 at 12:48