await db.transaction(async tx => {
const hasUser = await tx.query.users.findFirst(...);
if (hasUser) {
throw new Error("User already exists");
}
// ^ This doesn't work right?
const hasToken = await tx.query.token.findFirst(...);
if (hasToken) {
throw new Error("Token already exists");
}
// ^ Neither does this?
const token = await tx.insert(token).values(...);
});
await db.transaction(async tx => {
const hasUser = await tx.query.users.findFirst(...);
if (hasUser) {
throw new Error("User already exists");
}
// ^ This doesn't work right?
const hasToken = await tx.query.token.findFirst(...);
if (hasToken) {
throw new Error("Token already exists");
}
// ^ Neither does this?
const token = await tx.insert(token).values(...);
});