Back
Version 49
12/22/2023
import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
import { parseNotionDateDoc } from "https://esm.town/v/stevekrouse/date_me_doc_helpers";
import { dateMeNotionDatabase } from "https://esm.town/v/stevekrouse/dateMeNotionDatabase";
function jsonifyDoc(doc) {
return Object.fromEntries(
Object.entries(doc)
.filter(([key, value]) => value)
.map(
([key, value]) => [key, key === "Age" ? -(-value) : JSON.stringify(value)],
),
);
}
async function addDoc(doc) {
let keys = Object.keys(doc);
let sql = `INSERT INTO DateMeDocs
(${keys.join(", ")})
VALUES
(${keys.map(k => ":" + k).join(", ")})`;
try {
const result = await sqlite.execute({
sql,
args: doc,
});
return result;
} catch (e) {
console.log("error");
console.log(e.message);
console.log(sql);
}
}
// await sqlite.execute("delete from DateMeDocs");
const notionDocs = await dateMeNotionDatabase;
Updated: March 18, 2024