Transaction Operations Chaining — using result in queries inside the transaction?

Tricky question which perhaps has the answer “that’s not possible”:

Say you have a transaction with the 1st operation being a “find” operation. Then you want to run a second operation which is also a “find”, but you want to use part of the result of the 1st operation (e.g. “objectId” in the 1st item of that result) in the WHERE CLAUSE of the second operation… is this possible?

Our specific use case: user logs in and we want to run a transaction where we find an object they own in one table… and then we want to find all the objects in another table which are related to that first object… so we can get various things our app needs for the user to navigate around in a single transaction on log in. Any help much appreciated :grinning:

What you describe is possible. For transaction operations chaining, I recommend starting here:

With your specific use-case, I think it should be possible to do with one query though.

Yeah, I watched that video… and asked the same question on YouTube :grinning:

Right now, have a workaround (using email of current user in all queries in the operations, sometimes with a chain of “” in the query. Seems to work well :+1:

Do you need a sample showing it in the chaining or help with a single query that fetches the data?

Kind of related, and also related to “optimize to cut down on API calls” in light of the Scale Plan pricing… when getting the result of an operation in a transaction (after the transaction completes) like so:

Is that an API call or is that just getting data from the users browser, as found in “Preview” in “Network”?

An example would be awesome (where operation 2 is a “find” with a query that contains part of the result of the previous operation) :grin:

Hello @Alex_Klein

Get Transaction Result do not make a call to the server. Here is an example

Now when I call the method I got:

1 Like