Would like to do multiple updates via my API using mssql
transactions.
Example:
- Shipping Table
- Listing Table
- User_Notes Table
- Customer_Login Table
- Push_Notification Table
Which is the right way of doing it?
I was thinking at first of doing it with raw queries.
BEGIN TRANSACTION
CREATE IN SHIPPING
UPDATE IN LISTING
CREATE IN USER_NOTES
UPDATE IN CUSTOMER_LOGIN
CREATE IN PUSH_NOTIFICATION
COMMIT
But want to avoid writing a big raw query like this.
Also can I use mssql Transactions and Queries with (request.query).
const transaction = new sql.Transaction(/* [pool] */)
transaction.begin(err => {
// ... error checks
const request = new sql.Request(transaction)
request.query('create in shipping table', (err, result) => {
// ... error checks
transaction.commit(err => {
// ... error checks
console.log("Transaction committed.")
})
})
request.query('Update in Listing Table', (err, result) => {
// ... error checks
transaction.commit(err => {
// ... error checks
console.log("Transaction committed.")
})
})
and so on...
.
.
.
})