Any functions you perform on your Pages project is just a worker, so the same limits apply
Any functions you perform on your Pages project is just a worker, so the same limits apply
d1.batch call in the next query? I'm worried that sending a read query to find a specific row, waiting for the results in JS, and then sending a write query may end up with 2 workers trying to edit the same row.SELECT query into my UPDATE query and using LIMIT 1 so I can do everything in a single query.
db rather than tx does.returned. If i have to put them into an array like so:returned variable i can now use, so what do i do?db.transaction(async (tx) => {
const returned = await tx
.insert(schema.universities)
.values({ handle: form.data.handle })
.returning({ id: schema.universities.id });
await tx.insert(schema.localizedUniversityNames).values({
university: returned[0].id,
languageTag: form.data.languageTag,
name: form.data.name,
});
});To execute a transaction, please use the state.storage.transaction() API instead of the SQL BEGIN TRANSACTION or SAVEPOINT statements. The JavaScript API is safer because it will automatically roll back on exceptions, and because it interacts correctly with Durable Objects' automatic atomic write coalescing.Error: D1_ERROR: not authorized: SQLITE_AUTH
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SQLiteD1Session.transaction (...) {
[cause]: Error: not authorized: SQLITE_AUTH
at D1Database._sendOrThrow (cloudflare-internal:d1-api:67:24)
at async D1PreparedStatement.run (cloudflare-internal:d1-api:178:29) {
[cause]: undefined
}
}const returned = await tx
.insert(schema.universities)
.values({ handle: form.data.handle })
.returning({ id: schema.universities.id });
await tx.insert(schema.localizedUniversityNames).values({
university: returned[0].id,
languageTag: form.data.languageTag,
name: form.data.name,
});db.bulk([
db.insert(schema.universities).values({ handle: form.data.handle }).returning({ id: schema.universities.id }),
db.insert(schema.localizedUniversityNames).values({university: returned[0].id,languageTag: form.data.languageTag,name: form.data.name}),
]);d1.batchSELECTUPDATE