I also came across your PR @aveprik in Using Database Transactions to Write Queries in Strapi - #8 by aveprik
And I also can’t understand why strapi does not document the lack of transaction in v4.
You start updating and find out that more and more features were taken away from you OR have been changed in a fundamental way (components in lifecycle ).
With the addiotion of folders strapi even by themself seems to see the lack of transaction…
// fetch existing folder
const existingFolder = await strapi.db
.queryBuilder(FOLDER_MODEL_UID)
.select(['uid', 'path'])
.where({ id })
.transacting(trx)
.forUpdate()
.first()
.execute();
// update parent folder
const joinTable = strapi.db.metadata.get(FOLDER_MODEL_UID).attributes.parent.joinTable;
await strapi.db
.queryBuilder(joinTable.name)
.transacting(trx)
.update({ [joinTable.inverseJoinColumn.name]: parent })
.where({ [joinTable.joinColumn.name]: id })
.execute();
// fetch destinationFolder path
let destinationFolderPath = '/';
if (parent !== null) {
const destinationFolder = await strapi.db
.queryBuilder(FOLDER_MODEL_UID)
.select('path')
.where({ id: parent })
.transacting(trx)
.first()
.execute();
destinationFolderPath = destinationFolder.path;
}
So I hope Strapi reconsiders its decision regarding transaction or atleast communicates much better with the developer community. (maybe start using this forum more, even if it is painful someday)
I am really looking forward to the improvement of the documentation
until end (?) of september.