From ea7078be04a8a76e56498931196840d8473b079b Mon Sep 17 00:00:00 2001 From: Raphael Darley Date: Wed, 26 Jun 2024 09:21:08 +0100 Subject: [PATCH] add skv --- .gitignore | 3 ++- lib-src/embedded.ts | 1 + package.json | 4 ++-- test.ts | 38 ++++++++++++++++++++++++++++++++++++++ tests.ts | 22 ---------------------- 5 files changed, 43 insertions(+), 25 deletions(-) create mode 100644 test.ts delete mode 100644 tests.ts diff --git a/.gitignore b/.gitignore index 70aec80..29c0d97 100644 --- a/.gitignore +++ b/.gitignore @@ -234,4 +234,5 @@ $RECYCLE.BIN/ examples .idea -lib/* \ No newline at end of file +lib/* +test.skv \ No newline at end of file diff --git a/lib-src/embedded.ts b/lib-src/embedded.ts index f602082..ff697cc 100644 --- a/lib-src/embedded.ts +++ b/lib-src/embedded.ts @@ -145,5 +145,6 @@ export function surrealdbNodeEngines(opts?: ConnectionOptions) { return { mem: NodeEmbeddedEngine, + surrealkv: NodeEmbeddedEngine, } } diff --git a/package.json b/package.json index 6539dae..59a1b2e 100644 --- a/package.json +++ b/package.json @@ -54,9 +54,9 @@ "scripts": { "artifacts": "node move_artifacts.js", "build": "napi build --platform --release && bash ./fix-deps.sh", - "build:debug": "napi build --platform && bash ./fix-deps.sh && yarn ts-compile", + "build:debug": "napi build --platform && bash ./fix-deps.sh && tsc", "prepublishOnly": "napi prepublish -t npm", - "test": "npm install --global tsx && tsx tests.ts", + "test": "npm install --global tsx && tsx test.ts", "universal": "napi universal", "version": "napi version", "ts-compile": "npm install --global typescript && tsc --version && tsc" diff --git a/test.ts b/test.ts new file mode 100644 index 0000000..9280f4e --- /dev/null +++ b/test.ts @@ -0,0 +1,38 @@ +import Surreal from "surrealdb.js"; +import { surrealdbNodeEngines } from "./lib-src/embedded.ts"; + +async function run_mem() { + const surreal = new Surreal({ + engines: surrealdbNodeEngines() + }); + + console.log("connecting mem", await surreal.connect("mem://", { versionCheck: false })); + + console.log("using mem", await surreal.use({ namespace: "test", database: "test" })); + + console.log("listening mem", await surreal.live("test", (res) => console.log("recieved live" + res))); + + console.log("creating mem", await surreal.create('test', { val: 42 })); + + console.log("selecting mem", await surreal.select('test')); + + console.log("closing mem", await surreal.close()); +} + +async function run_skv() { + const surreal = new Surreal({ + engines: surrealdbNodeEngines() + }); + + console.log("connecting skv", await surreal.connect("surrealkv://test.skv", { versionCheck: false })); + + console.log("using skv", await surreal.use({ namespace: "test", database: "test" })); + + console.log("creating skv", await surreal.create('test', { val: 42 })); + + console.log("selecting skv", await surreal.select('test')); + +} + +// run_mem() +run_skv() \ No newline at end of file diff --git a/tests.ts b/tests.ts deleted file mode 100644 index 27314ef..0000000 --- a/tests.ts +++ /dev/null @@ -1,22 +0,0 @@ -import Surreal from "surrealdb.js"; -import { surrealdbNodeEngines } from "./lib-src/embedded.ts"; - -async function run_mem() { - const surreal = new Surreal({ - engines: surrealdbNodeEngines() - }); - - console.log("connecting", await surreal.connect("mem://", { versionCheck: false })); - - console.log("using", await surreal.use({ namespace: "test", database: "test" })); - - console.log("listening", await surreal.live("test", (res) => console.log("recieved live" + res))); - - console.log("creating", await surreal.create('test', { val: 42 })); - - console.log("selecting", await surreal.select('test')); - - console.log("closing", await surreal.close()); -} - -run_mem() \ No newline at end of file