Skip to content

Commit

Permalink
Fix serialization not working on Deno Deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
juliendorra committed Nov 26, 2023
1 parent 03dbf81 commit 8e05c03
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
13 changes: 11 additions & 2 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion kv-storage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { kvdex, model, collection } from "https://deno.land/x/kvdex/mod.ts";
import { Serializer } from "https://deno.land/x/superserial/mod.ts";
import { ulid } from "https://deno.land/std/ulid/mod.ts";

// Defining the Group type
Expand All @@ -22,14 +23,19 @@ const GroupsModel = model<Groups>();
// Open the KV database
const kv = await Deno.openKv();

const serializer = new Serializer();

// Setting up the database with collections
const db = kvdex(kv, {
apps: collection(GroupsModel, {
indices: {
urlid: "secondary",
timestamp: "secondary",
},
serialized: true,
serialized: {
serialize: serializer.serialize,
deserialize: serializer.deserialize,
},
// ulids can be ordered by insertion time, contrary to default kvdex crypto.randomUUID().
// https://github.com/oliver-oloughlin/kvdex/issues/126#issuecomment-1826809952
idGenerator: () => ulid()
Expand Down

0 comments on commit 8e05c03

Please sign in to comment.