Skip to main content

Hello I have a Firebase database collection that I want to use as trigger to update a row in a Google Sheet.

 

I looked at the documentation, but I am having trouble getting the Structured Query format correct when I try to include a Where property in addition to OrderBy. I am not that great with JSON and am probably just connecting them together incorrectly. I have tried all sorts of combinations of both inline and nested but still get generic JSON error for formatting. The documentation does not give an example of them combined.

 

    "orderBy": "{
"field": {
"fieldPath": "someKeyOfYourChoice"
},
"direction": "DESCENDING"
}]

"where": {
"fieldFilter": {
"field": {
"fieldPath": "whenPlayed"
},
"op": "EQUAL",
"value": {
"stringValue": "some-compare-to-value"
}
}
}



Can someone help me create a sample Structured Query with both OrderBy and Where properties?

Relevant details: neither my orderby key nor my where key will have spaces or weird characters. orderby will be timestamp object and where is going to be int value, not string.

Thanks!

Hi @Algorant 

I haven’t used Firebase but I would think something like this 

    "where": {
"fieldFilter": {
"field": {
"fieldPath": "whenPlayed"
},
"op": "EQUAL",
"value": {
"stringValue": "some-compare-to-value"
}
}
},
"orderBy": B{
"field": {
"fieldPath": "someKeyOfYourChoice"
},
"direction": "DESCENDING"
}]

Documentation for the structure can be found here: https://firebase.google.com/docs/firestore/reference/rest/v1beta1/StructuredQuery