mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2026-08-31 19:03:45 +02:00
Extend transaction usage
This commit is contained in:
+10
-5
@@ -158,14 +158,19 @@ export const createSyncRouter = ({ database, websocket, connectedDevicesManager,
|
||||
throw new BadRequest()
|
||||
}
|
||||
|
||||
const removedEntry = await database.oldDevice.findOne({
|
||||
where: {
|
||||
deviceAuthToken: req.body.deviceAuthToken
|
||||
}
|
||||
const isDeviceRemoved: boolean = await database.transaction(async (transaction) => {
|
||||
const removedEntry = await database.oldDevice.findOne({
|
||||
where: {
|
||||
deviceAuthToken: req.body.deviceAuthToken
|
||||
},
|
||||
transaction
|
||||
})
|
||||
|
||||
return !!removedEntry
|
||||
})
|
||||
|
||||
res.json({
|
||||
isDeviceRemoved: !!removedEntry
|
||||
isDeviceRemoved
|
||||
})
|
||||
} catch (ex) {
|
||||
next(ex)
|
||||
|
||||
Reference in New Issue
Block a user