Waiting for your reply, my service has been interrupted for 3 hours and customers have been asking m
Waiting for your reply, my service has been interrupted for 3 hours and customers have been asking me when it will be restored.
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?d1 in the github repo linked in the docs, and it creates the db for testing using migrations. I expected to test my local d1 directly and this will know my local db from my bindings (toml is passed to vitest.config.mts).Internal error in D1 storage caused object to be reset.

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.dbtxError: 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
}
}returnedreturnedd1vitest.config.mtsInternal error in D1 storage caused object to be reset.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,
});
});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}),
]);import { env } from "cloudflare:test";
import { describe, it, expect } from "vitest";
import { Env } from "../src/index.js";
//This is in the docs for env
declare module "cloudflare:test" {
interface ProvidedEnv extends Env {}
}
it("Prepared statements", async () => {
//test some function that uses env, but doesn't query d1, and it works
...
//test some function which queries my local d1 db
// doesn't found the table/s used in my query, sql error.
const table_list = await env.MY_DB.exec("pragma table_list;");
console.log("Table list:", table_list);
// which prints: Table list: { count: 1, duration: 0 }
})