Skip to content

Commit 75c9b45

Browse files
committed
refactor db-session.js to replace Promise.try with async/await for improved readability and error handling in atomic and transaction methods
1 parent 31cfea3 commit 75c9b45

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

db-session.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ const api = module.exports = {
4545

4646
atomic (operation) {
4747
return function atomic$operation () {
48-
return Promise.try(() => {
49-
const args = [].slice.call(arguments)
50-
return api.session.atomic(operation.bind(this), args)
51-
})
48+
const args = [].slice.call(arguments)
49+
return (async () => {
50+
return await api.session.atomic(operation.bind(this), args)
51+
})()
5252
}
5353
},
5454

5555
transaction (operation) {
5656
return function transaction$operation () {
57-
return Promise.try(() => {
58-
const args = [].slice.call(arguments)
59-
return api.session.transaction(operation.bind(this), args)
60-
})
57+
const args = [].slice.call(arguments)
58+
return (async () => {
59+
return await api.session.transaction(operation.bind(this), args)
60+
})()
6161
}
6262
},
6363

0 commit comments

Comments
 (0)