-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update examples: bare-node and bare-browser
- Loading branch information
1 parent
458a18b
commit ce9922b
Showing
7 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { createRequire } from 'module'; | ||
|
||
const require = createRequire(import.meta.url); | ||
const KUZU_DIST = path.dirname(require.resolve('@kuzu/kuzu-wasm')); | ||
|
||
function printErr(err) { | ||
if (err) return console.log(err); | ||
} | ||
fs.cp(path.resolve(KUZU_DIST), './dist', { recursive: true }, (err) => { | ||
if (err) { | ||
console.error(err); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Kuzu WASM Example</title> | ||
<script type="module"> | ||
import kuzu_wasm from './dist/kuzu-browser.js'; | ||
|
||
(async () => { | ||
const kuzu = await kuzu_wasm(); | ||
window.kuzu = kuzu | ||
const db = await kuzu.Database() | ||
const conn = await kuzu.Connection(db) | ||
await conn.execute(`CREATE NODE TABLE User(name STRING, age INT64, PRIMARY KEY (name))`) | ||
await conn.execute(`CREATE (u:User {name: 'Alice', age: 35});`) | ||
const res = await conn.execute(`MATCH (a:User) RETURN a.*;`) | ||
const res_json = JSON.parse(res.table.toString()); | ||
console.log(res_json) | ||
})(); | ||
</script> | ||
</head> | ||
<body> | ||
<h1>Kuzu WASM Example</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"private": true, | ||
"name": "kuzu-wasm-examples-bare-browser", | ||
"version": "0.0.1", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@kuzu/kuzu-wasm": "file:../../packages/kuzu-wasm" | ||
}, | ||
"devDependencies": { | ||
}, | ||
"scripts": { | ||
"build": "node ./bundle.mjs" | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const kuzu_wasm = require('@kuzu/kuzu-wasm'); | ||
const path = require('path'); | ||
const DUCKDB_DIST = path.dirname(require.resolve('@kuzu/kuzu-wasm')); | ||
|
||
(async () => { | ||
const kuzu = await kuzu_wasm(); | ||
const db = new kuzu.WebDatabase("memDB", 0, 0, false, false, 4194304 * 16 * 8); | ||
const conn = new kuzu.WebConnection(db, 0); | ||
await conn.query(`CREATE NODE TABLE User(name STRING, age INT64, PRIMARY KEY (name))`) | ||
await conn.query(`CREATE (u:User {name: 'Alice', age: 35});`) | ||
const res = await conn.query(`MATCH (a:User) RETURN a.*;`) | ||
console.log(res.toString()) | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"private": true, | ||
"name": "kuzu-wasm-examples-bare-node", | ||
"version": "0.0.1", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@kuzu/kuzu-wasm": "file:../../packages/kuzu-wasm" | ||
}, | ||
"scripts": { | ||
"test": "node ./index.cjs" | ||
} | ||
} |