Async queries or something else

Hello. Try to describe what exactly I want to do:
I have a table t_Components and selector editComponent_packageId
Selector has Default value {{}}
Near it I added an icon that open Modal window.
Button Add New triggers a query that add one more row to table

INSERT INTO i_packages (package,pinQuantity,isSmd) VALUES ({{newPackage_name.value}},{{newPackage_pins.value}},{{newPackage_isSMD.value}})

And has a few handlers for Success:
1 - refresh list of available values for selector
2 - get last Id with query SELECT MAX(id) as newId FROM i_packages;
3 - set value in selector editComponent_packageId to {{[0]}}
4 - closed modal window

The question is: why I saw PREVIOUSLY ADDED (max -1) value in the Selector:

My table has the followint structure:



Hey @alk0v! Thank you for such a clear description.

You mentioned that you have an INSERT query running with a few Success handlers.

Are all of these queries attached to your INSERT query? If so, maybe these actions are running out of order (since there's not clear run order with event handlers attached to the same query).

Would you be able to attach the editComponent_packageId setValue event directly to the getNewPackageId query?

1 Like

Yeap. It solved my problem. Many thanks.

Let me know! :crossed_fingers:

1 Like

Amazing!!! So glad to hear it :slight_smile:

1 Like