Reputation: 5655
I am designing a data structure to be stored in Google Datastore.
I like to query All Applications belonging to a particular category I also like to get a sum total of the number of applications in a given category.
To achieve this i have designed the following classes.
application.py
from google.appengine.ext import ndb
from cfc.models.admin.applicationcategory import ApplicationCategory
class Application(ndb.model):
""" Application Model"""
name = ndb.StringProperty()
category = ApplicationCategory()
applicationcategory.py
from google.appengine.ext import ndb
class ApplicationCategory(ndb.model):
"""Models an application Category"""
name = ndb.StringProperty()
date_created = ndb.DateTimeProperty(auto_now_add=True)
My questions are how does one define the queries given that, datastore is eventually consistent ?
Upvotes: 0
Views: 84
Reputation: 9484
Datastore is not optimized for this type of scenario. The best option to get the count of application based on a given category is to use the search api. Create a document for each application and add category as a facet. Then you can use faceted search to get the count using facet value query.
Upvotes: 1