How to access variables from Firebase Raw Mode? (again)

Goal

  • I'm trying to pass information from a query to a Firebase Raw mode query. I have to use Firebase Raw mode because I'm trying to increment a value (so I want to use firestore.FieldValue.increment(n) - which is working great!)
  • However, I can't figure out how to access variables/other queries/form data from my Firebase query in raw mode - every time I do, I get SyntaxError: Unexpected token '{'

Steps

  • When I do my Firebase query with purely static data, it works fine e.g. I can run something like:

    const id = "static-id";
    const amount = 3;
    
    return await db.firestore()
      .collection('someCollection')
      .doc(id)
      .update({ "someProperty": firestore.FieldValue.increment(amount) });
    

    And this will happily run the query and shows the document was modified successfully.

  • But as soon as try to use a variable for the amount, or the id of the document to modify, it gives SyntaxError: Unexpected token '{'

Details

  • This seems similar to this previously reported issue: How to access variables from Firebase Raw Mode?
    • But unlike in that one, no amount of swapping between GUI and Raw mode allows my query to start working
    • I also tried creating a fresh query, but it didn't seem to help
  • None of the "pre-populated examples" show how to use data from other queries

Screenshots

I think this is a minimal reproduction?

I might try this approach and report back: Having trouble passing parameters/setting nested fields in a raw mode Firestore Update query - #2 by serena

Reporting back: saving the Firebase raw query as a query to the shared library didn't help - it runs fine until the input variables (on the "import from library" query) contain expressions, then fails the same way.

Similarly, triggering the Firebase raw query from a JS query, with additionalScope, didn't work either (the triggering failed with the same 500 error)

So, I can't find a way to get firestore.FieldValue.increment(n) to work with dynamic data at all - I suspect there's no support for variable expressions at all when working within a raw query?

Hey @nzdominic, Thanks for posting your question on the forum :blush: Within Firebase Raw queries you can reference Retool values with plain text—the {{ }} syntax isn't required. Hope that helps to unblock you!