From 556553ce1a5c76da66c2edab7dd9af4bf83e1376 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Fri, 27 Dec 2024 11:02:11 -0600 Subject: [PATCH] Db --- db.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db.ts b/db.ts index ddfb89d..0c1d86b 100644 --- a/db.ts +++ b/db.ts @@ -30,16 +30,17 @@ export function all( type Create = Omit | Partial -export function create( +export async function create( a: T, payload: Create, -): Deno.KvListIterator> { +): Promise { const data: Create> | undefined = schema[a].parse(payload) + // we want to create our own ID since this is `create` and not `update` if (Identifiable.safeParse(data).success) { delete data.id } if (Created.safeParse(data).success) { delete data.createdBy } - return kv.set([a, ) + return await kv.set([a, payload.id], payload) }