|
|
@@ -1,7 +1,7 @@
|
|
|
import { DB } from "$sqlite/mod.ts";
|
|
|
|
|
|
function prepareDB(tableName: string) {
|
|
|
- const db = new DB("postdown.db");
|
|
|
+ const db = new DB("data/postdown.db");
|
|
|
switch (tableName) {
|
|
|
case "User":
|
|
|
db.execute(`
|
|
|
@@ -73,7 +73,10 @@ export function insert(
|
|
|
userInsertObject: { [key: string]: string | number | boolean }
|
|
|
) {
|
|
|
const db = prepareDB(tableName);
|
|
|
- const insertObject = { ...userInsertObject, updated: new Date() };
|
|
|
+ const insertObject = {
|
|
|
+ ...userInsertObject,
|
|
|
+ updated: new Date().toISOString().slice(0, 19).replace("T", " "),
|
|
|
+ };
|
|
|
const insertQuery = db.prepareQuery(
|
|
|
`INSERT INTO ${tableName.toLowerCase()} (${Object.keys(insertObject).join(
|
|
|
", "
|
|
|
@@ -99,7 +102,10 @@ export function update(
|
|
|
userUpdateObject: { [key: string]: string | number | boolean }
|
|
|
) {
|
|
|
const db = prepareDB(tableName);
|
|
|
- const updateObject = { ...userUpdateObject, updated: new Date() };
|
|
|
+ const updateObject = {
|
|
|
+ ...userUpdateObject,
|
|
|
+ updated: new Date().toISOString().slice(0, 19).replace("T", " "),
|
|
|
+ };
|
|
|
const updateQuery = db.prepareQuery(
|
|
|
`UPDATE ${tableName.toLowerCase()} SET ${Object.keys(updateObject)
|
|
|
.map((updateKey) => `${updateKey} = :${updateKey}`)
|