I am working on a web system where a feature is similar to Twitter's concept of following a list of users and seeing their posts as a list.
The simple model I came up with requires join operation which is not available in datastore.
class Post(Model):
author = reference to user id
content = text content
class Following(Model):
author = reference to user id
followed_by = reference to user idThe frequent operation is to display a list of posts (sorted in time) from users followed by the current user.
With the above model, it can only be done in two steps:
authors = Following.author when Following.followed_by == current_user
posts = Posts with Posts.author in authorsIs there any way to achieve this more efficiently?
--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscribe@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/9480ad51-6530-4fa6-a23d-88d215d525a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I would recommend denormalizing your data model -- a common optimization in non-relational DBs (like the datastore) and frequently useful in relational DBs as well. Just have user entities, with the user id as their key's name, containing a list of the authors the user follows. This will make adding/removing a follower relationship minutely slower, but surely that's a far rarer operation than displaying appropriate lists of posts.For more on denormalization, start e.g. from https://en.wikipedia.org/wiki/Denormalization .Alex
On Thu, Jun 15, 2017 at 4:19 AM, Suresh Jeevanandam <jm.s...@gmail.com> wrote:
I am working on a web system where a feature is similar to Twitter's concept of following a list of users and seeing their posts as a list.
The simple model I came up with requires
joinoperation which is not available indatastore.class Post(Model): author = reference to user id content = text content class Following(Model): author = reference to user id followed_by = reference to user idThe frequent operation is to display a list of posts (sorted in time) from users followed by the current user.
With the above model, it can only be done in two steps:
authors = Following.author when Following.followed_by == current_user posts = Posts with Posts.author in authorsIs there any way to achieve this more efficiently?
--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.