A question about queries/transactions:
If a document exists, then I want to create a different document and also delete document 1.
The problem is that deleting the document seems to trigger the abort
call.
let inv = Invitation
.by_token(${token})
.first()
if (inv == null) {
abort("Bad invitation token")
}
if (inv!.status != "pending") {
abort("That invitation has been used already.")
}
let user = User.create({
email: inv!.email,
dbName: inv!.dbName,
password: ${hashedPassword}
}) { id, email, dbName }
inv!.delete()
user
This query throws because the abort("Bad invitation token")
is called, even though the invitation exists. I’m guessing that the inv.delete
at the end is causing that, which is surprising to me.