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
Yeah, I watched that video… and asked the same question on YouTube
Right now, have a workaround (using email of current user in all queries in the operations, sometimes with a chain of “xxxxx.yyyyyy.email” in the query. Seems to work well
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:
I looked into it and I believe it is not possible for the following reason:
At the time when the where clause is composed for the second query, the result from the first one is not available. The where clause cannot include a reference to a result, it should be a complete scalar value by the time the entire sequence of operations is sent to the server in the transaction. Here’s a visual representation of what I mean:
I apologize for not catching it earlier at the beginning of this thread.
The following graphic from our docs actually shows that none of the errors come into the “Retrieving Objects” block, this means the data retrieval operation cannot use a result of another operation: