Efficient way to get child / keys based on parent

I wanted to ask if there is a direct and efficient way to get the child of the parent object.

I model a follow / following relationship (e.g. twitter). So I have a user model and a message model. I have a Follower and Next model that has a user model as a parent.

Therefore, whenever a user writes a message (or says a tweet), all of his followers should be able to receive it. In this case, I need to find out who the followers of the user (who sends the message) are.

Any help is appreciated

+5
source share
2 answers

ndb.Query, ancestor :

joe = Followed.get_by_id('joe')

query = ndb.Query(ancestor = joe.key)

followers = query.fetch()

, , Kind .

0

All Articles