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) }