Does libasynql uses the queue system(one after another) for executing the sql queries in an async way or are they randomly executed? I tried searching about this but couldnt find an answer on the repo.
Short answer: this is undefined behaviour. There may be multiple queries running at undefined order at the same time, and the database engine decides how to handle concurrency. Long answer: libasynql uses a number of async workers, as specified in the config file. There is a global queue of queries to execute, and the workers will start executing the queries in the same order as scheduled. However, the order in which workers start executing is not the same as the order in which the database engine (e.g. MySQL server, or the filesystem locks for SQLite3) receives and actually runs the query. If there is only one query, it is less likely to have race conditions, but you should still not rely on this behaviour for correctness of queries. If you would like to ensure that queries are executed in order, you should execute the subsequent queries in the $onComplete parameter. Furthermore, libraries such as await-generator might help you achieving async callback in a more friendly syntax, but those have higher learning curve and are not recommended unless your program is primarily composed of complex callback logic.