export const insert_logs_from_batch = async (
batch: MessageBatch<logSchema>,
env: Bindings
): Promise<InsertBatchLogsResponse> => {
const db = drizzle(env.DB);
const refine_batch = batch.messages.map((log) => {
return db.insert(logs).values({
...log.body
}) as BatchItem<"sqlite">; // <--casting as BatchItem cause original type doesn't match as batchItem
});
try {
const res = await db.batch([...refine_batch]); // --> Getting the type error here. it works on runtime
return { success: true, data: null };
} catch (err) {
return { success: false, error: err };
}
};
export const insert_logs_from_batch = async (
batch: MessageBatch<logSchema>,
env: Bindings
): Promise<InsertBatchLogsResponse> => {
const db = drizzle(env.DB);
const refine_batch = batch.messages.map((log) => {
return db.insert(logs).values({
...log.body
}) as BatchItem<"sqlite">; // <--casting as BatchItem cause original type doesn't match as batchItem
});
try {
const res = await db.batch([...refine_batch]); // --> Getting the type error here. it works on runtime
return { success: true, data: null };
} catch (err) {
return { success: false, error: err };
}
};