Search code examples
google-app-enginenosqldatastore

The best way to associate an user with an entity in Apps Engine


This may be a silly question but i'm totally new to Apps Engine and NoSQL's logic so i'm asking for a suggestion.

I suppose there is an optimal and well-known way to associate an user with an entity in the datastore and i would like to know how to do that, maybe with a guide or a brief example.

I have an user that can subscribe to a Node. I need to know the optimal way to associate these two entities, the best way to check if an user has subscribed to a node and the list of nodes an user has subscribed to.

Thank you in advance^^


Solution

  • if you use python:

    class Node(db.Model):
      user = db.UserProperty()
    
    user = users.get_current_user()
    qry = db.GqlQuery("SELECT * FROM Node WHERE user = :1", user)
    

    For the rest see the docs