I assume that you can’t, and that you can only batch operations on the database in the state it’s in before ANY of the operations are run. But I thought I’d check, because FIbery continues to pleasantly surprise me, and you never know…
Hi there, api/commands indeed accepts an array of commands, however there is a catch.
this commands will be executed sequentially
if one command fails it won’t stop execution
each command will run in a separate transaction
You may try fibery.command/batch, for example it’s used here Fibery API for creating Single Select and populate it with some select-items in one batch.
To achieve your behaviour with "SOME_KIND_OF_REFERENCE_TO_THE_FIRST_RESULTS" we usually recommend the following approach:
generate fibery/id upfront for each entity to be created. It should be UUID version 4 e.g. crypto.randomUUID() in nodejs.
then use this fibery/id in update / delete / add-collection-item commands.
Also please mind that you can set Reference values in Entity create command, so you don’t need to split it into several commands in that case, however it is not the case for adding Entity into some other Entity collection field.
Woah, you can generate the ID ahead of time??? That’s wonderful. Yeah, in this case, I’m trying to connect a collection reference field, but this is good to know for later.