Reputation: 1261
I have an entity in my system which will have a lot of comments added against it in a short period of time.
Would I be correct in saying that if I read a document and then modify something in it, the entire object is then persisted back to the store?
If this is correct, then loading and storing an object with 5000 comments just so that I can add a comment seems like a bit too much?
Should I store each comment as a document and then scan through the document collection for a particular key? I would also need to be able to quickly find a comment and modify it.
Upvotes: 3
Views: 463
Reputation: 2693
One massive document
If you would like to store all comments in one document you will run into few issues:
Pros:
Multiple collections
The best option I guess is splitting comment and main objects into two collections and link every comment to the main object by id. This way you can add and edit single comment as well as retrieve all documents by query. This way you can run much more complex queries on comments collection for instance - get all comments by user etc.
Cons:
Although you have to be aware that OrderBy clause is not supported yet, so you might have a problem retrieving for example last 10 comments etc.
Possible alternative
Not sure what are the other operations/queries you have to support. But if it’s only CRUD, retrieving list of comments for main object and potentially getting last x comments, you could consider using Azure Table where:
This way you can retrieve and update comment entity extremely fast and as well as query it by time
Upvotes: 1