Error: D1_ERROR: Error: not authorized

This works in local dev, and my other CRUD routes work without issue, however the following code throws error Error: D1_ERROR: Error: not authorized in production. Anybody have any ideas? Is something not supported in D1 like returning() or transactions or something? I'm using Miniflare in dev and it works here.
const newTeam = await locals.db
.transaction(async (tx) => {
const newTeam = await tx.insert(teams).values(form.data).returning().get();
await tx.insert(usersToTeams).values({
userId,
teamId: newTeam.id,
isAdmin: 1
});
return newTeam;
})
.catch((e) => {
console.log('ERROR: ', e);
throw error(500, 'Something went wrong creating your team.');
});
const newTeam = await locals.db
.transaction(async (tx) => {
const newTeam = await tx.insert(teams).values(form.data).returning().get();
await tx.insert(usersToTeams).values({
userId,
teamId: newTeam.id,
isAdmin: 1
});
return newTeam;
})
.catch((e) => {
console.log('ERROR: ', e);
throw error(500, 'Something went wrong creating your team.');
});
2 Replies
philwinder
philwinder15mo ago
FYI, same problem for me. Did you figure it out?
philwinder
philwinder15mo ago
GitHub
[BUG]: Transactions don't work with D1 · Issue #758 · drizzle-team/...
What version of drizzle-orm are you using? 0.26.5 What version of drizzle-kit are you using? 0.18.1 Describe the Bug It looks like D1 doesn't support standard transactions. begin immediate retu...
GitHub
[sqlite] Implement runInBatch for d1 by tjenkinson · Pull Request...
see #758 Happy to prepare a PR on the docs site to update those too if the approach here is ok. Initially I wanted to just add it to D1, but that would mean having to do an instanceof D1PreparedSta...
Want results from more Discord servers?
Add your server