I am making a simple app where one can post any thing and anyone can comment on that post. Do I need to create an entity group making every post as parent and comments as children?If I am wrong how to model the data having post and comment as entities? Documentation says there a limit of 1 write/sec If my app has high traffic like many people are commenting on the same post at the same time there will be a problem of transaction failure. How to solve this ?
-
1You need to have a go yourself first, as we can't just write code for you - try it, then ask a new question when you hit a coding problem. – ArtOfCode Dec 22 '14 at 19:19
-
think of it as a feature, rather then a problem to solve. – Paul Collingwood Dec 22 '14 at 19:47
1 Answers
Before you start coding on a new platform, first do a bit of research and try to fully understand all the features and nuances first.
To answer your question, YES, you can create an Entity Group with the original post as parent and then each comment as a child, but WHY?
What are you trying to achieve? Having a Post with comments attached to it, right? Why not just save all of them in ONE entity?
Entities have attributes (fields); so you can have POST, COMMENTS as field types of the Entity Thread. The COMMENTS attribute/field can be an array of strings or text or objects as you see fit.
So when you are displaying the data, fetch the Thread entity, and display its POST field (the original post), then underneath it, display the COMMENTS field (extract strings from the string array then display them in order).

- 2,500
- 2
- 13
- 37
-
But the problem I see here is entity size limit. If the post gets many comments then it obviously exceed the entity size limit i.e.,1MB then? – matrix Dec 23 '14 at 05:14
-
Then you start a new record and when you ask for children of the topic you get both sets of comments. – Paul Collingwood Dec 23 '14 at 10:16
-
Exactly. How you store the entity doesn't matter, what you should consider is cost. If you just structure your entity according to parent-children structure needlessly (by splitting up Post/Comments), then you are ALWAYS forced to do two fetches and two reads every time you pull a Post up with its comments. Data optimization is the name of the game here; without optimization, you can put EACH comment in an entity if you wish, it works... It's just really expensive. – Ying Li Dec 23 '14 at 17:09