try {
// Check if the DB is reachable
env.DB.prepare("SELECT 1").first();
const result = env.DB.prepare("INSERT INTO ... (...) VALUES (?, ?, ?, ?)")
.bind()
.run()
.then((result: unknown) => {
console.debug("Insertion result:", result);
})
.catch((error: unknown) => {
console.error("Error inserting data:", error);
throw error; // Rethrow to handle in the catch block
});
console.debug({ ... }, "logged to D1 database", { result });
} catch (err) {
console.error("Insertion into", { env }, "failed", err);
}
try {
// Check if the DB is reachable
env.DB.prepare("SELECT 1").first();
const result = env.DB.prepare("INSERT INTO ... (...) VALUES (?, ?, ?, ?)")
.bind()
.run()
.then((result: unknown) => {
console.debug("Insertion result:", result);
})
.catch((error: unknown) => {
console.error("Error inserting data:", error);
throw error; // Rethrow to handle in the catch block
});
console.debug({ ... }, "logged to D1 database", { result });
} catch (err) {
console.error("Insertion into", { env }, "failed", err);
}