Hi,
I have a JSON response returned from the baas notifications as below,
{
"pathQuery": {
"applicationRef": {
"type": "application",
"uuid": "25fd9a82-c1fa-11e5-9114-0677219f14f3"
},
"pathTokens": [{
"collection": "devices",
"identifier": {
"type": "UUID",
"value": "79870948-2f50-4632-93b6-b00b16557863"
},
"ql": null
}] }
}
I would like to query the results using the pathTokens.Identifier value, so I used the sql query string like,
select * where pathQuery.pathTokens.identifier.value='79870948-2f50-4632-93b6-b00b16557863'
but it's throwing error, i also tried other possibilities but i am stuck to fetch this from an array. Can someone help me how to fetch the string from an array using sql query in API BaaS?
Answer by Siddharth Barahalikar
·
Jan 05, 2019 at 04:18 AM
It is been a long time since I have seen BaaS Queries here.
Since BaaS is not available for free users, I don't remember much.
Your query looks correct, what is the error you get?
Can you try querying the value of sub-properties by,
?ql=pathQuery.pathTokens.identifier.value='79870948-2f50-4632-93b6-b00b16557863'
Thank you for replying back on this. I am getting an error message as "No entities found" after trying the select query.
Also, I can able to access the top level key:values by specifying respective id. For example from the json below,
{
"uuid": "5442d8e1-11f4-11e9-ab0e-02ffa652f380",
"type": "notification",
"state": "FINISHED",
"created": 1546807669487,
"modified": 1546807669673,
"pathQuery": {
"applicationRef": {
"type": "application",
"uuid": "25fd9a82-c1fa-11e5-9114-0677219f14f3"
},
If I query it like
"select * where uuid = '5442d8e1-11f4-11e9-ab0e-02ffa652f380'" is working
but if I traverse inside a nested block like
"select * where pathQuery.uuid= '25fd9a82-c1fa-11e5-9114-0677219f14f3'" is not working.
Let me know if need more details.
I'm not sure why it is not working, it is like querying sub-properties,
https://docs.apigee.com/api-baas/data-storage/querying-your-data#queryingsubproperties
?ql=pathQuery.applicationRef.uuid= '25fd9a82-c1fa-11e5-9114-0677219f14f3
In your previous comment, you made a typo, you missed out applicationRef
select * where pathQuery.applicationRef.uuid= '25fd9a82-c1fa-11e5-9114-0677219f14f3
I've corrected the query and tried but its returning the same results as "No entities found" . I have a qn on if the ql value set to nulll inside the block, cant we not able to query it if its set to null?
"ql": null
Answer by Dino-at-Google
·
Jan 07, 2019 at 06:01 PM
I'm not clear on what you are doing.
It sounds like your app receives a notification from BaaS. And you want to query or parse that notification in its JSON form. Is that right? Is this not strictly a client-side issue then?
If your question is how to query an array in BaaS, then maybe this will help:
https://stackoverflow.com/questions/25297308/how-do-i-query-arrays-in-usergrid-collections
Unfortunately, there are conflicting answers there. The one consistency is that query of sub-arrays is not well supported; there's a suggestion that a query with property = 'xxx' will evaluate as true if the xxx falls anywhere within the array elements .
I suggest that you try the idea from Michael Bissell: restructure your data to make it more easily queryable.
Thank you for the prompt response on this. Let me verify and get back on this.
"Contains" Query Parameter Containing Two or More Words 3 Answers
Can I query BaaS directly from a request policy or only via an HTTP request? 1 Answer
Apigee BaaS push notifications metrics 1 Answer
Apigee Baas - No collections found 3 Answers
Same query at BaaS, different responses based on where call is made from 0 Answers