Hi,
I have a requirement where I need to search for users in a BAAS collection where they have more than 300 entities. However, I have noticed that the query language doesn't support count.
"API BaaS is not an RDBMS. It does not include RDBMS features such as count(*)
and cross-table joins."
See https://docs.apigee.com/api-baas/data-storage/evaluating-api-baas-data-store
Has anyone found a way around this?
Answer by Imesh Gunaratne · Nov 23, 2018 at 03:11 AM
The number of entities in a collection in Apigee BaaS can be found by using the following management API resource:
1. Make an API request to the following resource:
curl -n https://{baas-hostname}/{orgName}/{appName}/
2. Read the count property of the required collection:
A sample response may look like below:
{ "action": "get", "application": "xxx", "params": {}, "uri": "https://baas-hostname/org/app", "entities": [ { "uuid": "xxx", "type": "application", "name": "org/app", "accesstokenttl": null, "applicationName": "app", "organizationName": "org", "created": 1515202544207, "modified": 1515202544207, "metadata": { "collections": { "items": { "count": 8, "name": "items", "type": "item", "title": "items" } } } } ], "timestamp": 1542780918747, "duration": 36, "organization": "org", "applicationName": "app" }
Please note that the count value would not be accurate if the number of entities in the collection is considerably large.
More importantly, please note that Apigee has deprecated BaaS with the intension of reusing Google Cloud products such as Cloud Firestore, Cloud Datastore, Cloud Spanner, Cloud SQL, etc instead. Please find more information on this at [1].
[1] https://apigee.com/about/blog/api-technology/were-sunsetting-apigee-api-baas
Thanks!
Thanks... I am aware that the count is returned but I wanted to return entities from there query where the a certain user had more than 300. So it's a condition in the query.
All good. We are aware of the deprecation.