Question

Firebase Structured Query format to Trigger Event to Google Sheet

  • 18 May 2021
  • 1 reply
  • 986 views

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!


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 7
Badge +12

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": [{
"field": {
"fieldPath": "someKeyOfYourChoice"
},
"direction": "DESCENDING"
}]

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