I used to get the count of entities in a Class for a particular field value, as follows when I use the Google App Engine Python 2.7 NDB library as sample code below:
count = Product.query (Product.account_id == "myAccountID", Product.category == "myCategory"). Count (99999)
Now I'm switching to Python 3.7 using the Google Cloud Datastore API
https://googleapis.github.io/google-cloud-python/latest/datastore/index.html, unfortunately I could not find the COUNT function. I just found a way to get the total count for the whole entity in a Class using __Stat_Kind__, see the sample code below:
q = client.query (kind = "__ Stat_Kind__") q.add_filter ("kind_name", "=", "Product") r = q.fetch (limit = 1) account = 0 for x in r: account = x["count"]
The above example code will get the total count of entities for the Product Class, but if I want to get the total count in this Product Class with the value of the Category field equal to "myCategory"? Does anyone know how to do it?