sekejap 0.13.3 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,62 +1,86 @@
|
|
|
1
|
-
# sekejap
|
|
1
|
+
# sekejap
|
|
2
2
|
|
|
3
|
-
**
|
|
4
|
-
|
|
3
|
+
Embedded **graph-first, multi-model database** for Node.js — SQL + graph + vector +
|
|
4
|
+
spatial in one native library. No server, no external process; the whole engine runs
|
|
5
|
+
in-process on a Rust core.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
- **PostgreSQL-like SQL** — `CREATE TABLE`, `INSERT`, `SELECT … WHERE`, parameters (`$1`).
|
|
8
|
+
- **Graph** — link records and traverse relationships.
|
|
9
|
+
- **Prepared statements** — compile once, run many with varying parameters.
|
|
10
|
+
- **No native build** — the prebuilt binaries for every platform ship inside the
|
|
11
|
+
package. No Rust toolchain, no `node-gyp`, no compile step.
|
|
7
12
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
node test.cjs # → OK — sekejap-node 0.13.0 …
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install sekejap
|
|
13
17
|
```
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
per-platform and generates `index.js` + `index.d.ts` (TypeScript types). JS API:
|
|
17
|
-
`Db.open(path)`, `execute`, `query`/`queryParams` (→ JSON string, `JSON.parse` it),
|
|
18
|
-
`put`, `link`, `nodeCount`/`edgeCount`, `compact`, `version()`.
|
|
19
|
+
Works on macOS (arm64/x64), Linux (x64/arm64), and Windows (x64), Node ≥ 16.
|
|
19
20
|
|
|
20
|
-
##
|
|
21
|
+
## Quick start
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
idiomatic JS types, no manual C ABI. (An alternative is `koffi`/`ffi-napi` calling
|
|
25
|
-
the C ABI in `../c`, but napi-rs gives better perf and TypeScript types.)
|
|
23
|
+
```js
|
|
24
|
+
const { Db, version } = require('sekejap');
|
|
26
25
|
|
|
26
|
+
const db = Db.open('/tmp/notes'); // open (or create) a database directory
|
|
27
|
+
|
|
28
|
+
// Define a table and insert rows with SQL.
|
|
29
|
+
db.execute('CREATE TABLE note (_key TEXT PRIMARY KEY, title TEXT, pinned INTEGER)');
|
|
30
|
+
db.execute("INSERT INTO note (_key, title, pinned) VALUES ('n1', 'Buy milk', 1)");
|
|
31
|
+
|
|
32
|
+
// Insert a record directly (no SQL) as a JSON payload.
|
|
33
|
+
db.put('note/n2', JSON.stringify({ _collection: 'note', _key: 'n2', title: 'Call Sam', pinned: 0 }));
|
|
34
|
+
|
|
35
|
+
// Query. Results come back as a JSON string — JSON.parse it.
|
|
36
|
+
const notes = JSON.parse(db.query('SELECT * FROM note'));
|
|
37
|
+
console.log(notes);
|
|
38
|
+
// [ { _key: 'n1', title: 'Buy milk', pinned: 1, ... }, { _key: 'n2', ... } ]
|
|
39
|
+
|
|
40
|
+
// Parameterized query ($1, $2, …) — injection-safe. Params are a JSON array string.
|
|
41
|
+
const pinned = JSON.parse(db.queryParams('SELECT title FROM note WHERE pinned = $1', JSON.stringify([1])));
|
|
42
|
+
|
|
43
|
+
// Prepared statement — compile once, run many.
|
|
44
|
+
const byPin = db.prepare('SELECT _key FROM note WHERE pinned = $1');
|
|
45
|
+
for (const p of [0, 1]) {
|
|
46
|
+
console.log(JSON.parse(db.queryPrepared(byPin, JSON.stringify([p]))));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Graph: link two records.
|
|
50
|
+
db.link('note/n1', 'note/n2', 'related');
|
|
51
|
+
console.log('nodes:', db.nodeCount(), 'edges:', db.edgeCount());
|
|
52
|
+
|
|
53
|
+
// Flush + compact to disk after heavy writes.
|
|
54
|
+
db.compact();
|
|
27
55
|
```
|
|
28
|
-
wrappers/node/
|
|
29
|
-
├── Cargo.toml # crate-type = ["cdylib"], deps: napi, napi-derive; depends on the sekejap crate
|
|
30
|
-
├── package.json # name "sekejap", @napi-rs/cli build/publish scripts
|
|
31
|
-
├── src/lib.rs # #[napi] wrappers over sekejap::CoreDB / Engine
|
|
32
|
-
├── index.d.ts # generated TypeScript types
|
|
33
|
-
└── examples/ # .js / .ts usage
|
|
34
|
-
```
|
|
35
56
|
|
|
36
|
-
|
|
57
|
+
## API
|
|
58
|
+
|
|
59
|
+
| Method | Purpose |
|
|
60
|
+
|---|---|
|
|
61
|
+
| `Db.open(path)` | Open (or create) a database at a directory path |
|
|
62
|
+
| `db.execute(sql)` | Run DDL/DML (`CREATE`/`INSERT`/`UPDATE`/`DELETE`) → rows affected |
|
|
63
|
+
| `db.query(sql)` | Run a `SELECT`/graph query → **JSON string** |
|
|
64
|
+
| `db.queryParams(sql, paramsJson)` | Parameterized query; `paramsJson` is a JSON array string |
|
|
65
|
+
| `db.prepare(sql)` / `db.queryPrepared(stmt, paramsJson)` | Prepared statements |
|
|
66
|
+
| `db.put(slug, payloadJson)` | Insert/replace one record by slug with a JSON payload |
|
|
67
|
+
| `db.link(from, to, edgeType)` | Create a graph edge |
|
|
68
|
+
| `db.nodeCount()` / `db.edgeCount()` | Counts |
|
|
69
|
+
| `db.compact()` | Flush WAL, rewrite payloads, reclaim RAM |
|
|
70
|
+
| `version()` | Library version |
|
|
37
71
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
name = "sekejap-node"
|
|
41
|
-
version.workspace = true
|
|
42
|
-
edition.workspace = true
|
|
72
|
+
`query` / `queryParams` / `queryPrepared` return a **JSON string** — decode with
|
|
73
|
+
`JSON.parse(...)`. It's an array of row objects.
|
|
43
74
|
|
|
44
|
-
|
|
45
|
-
crate-type = ["cdylib"]
|
|
75
|
+
### TypeScript
|
|
46
76
|
|
|
47
|
-
|
|
48
|
-
sekejap = { path = "../.." }
|
|
49
|
-
napi = { version = "2", features = ["napi8"] }
|
|
50
|
-
napi-derive = "2"
|
|
77
|
+
Types ship with the package (`index.d.ts`) — no `@types` needed.
|
|
51
78
|
|
|
52
|
-
|
|
53
|
-
|
|
79
|
+
```ts
|
|
80
|
+
import { Db } from 'sekejap';
|
|
81
|
+
const db = Db.open('/tmp/notes');
|
|
54
82
|
```
|
|
55
83
|
|
|
56
|
-
##
|
|
84
|
+
## License
|
|
57
85
|
|
|
58
|
-
- **
|
|
59
|
-
- **Publish:** `npm publish`. Build prebuilt binaries per platform in CI with
|
|
60
|
-
`@napi-rs/cli` (`napi build --release`) and ship them as platform packages under
|
|
61
|
-
`optionalDependencies`, so users don't need a Rust toolchain.
|
|
62
|
-
- Reserve the name `sekejap` on npm now.
|
|
86
|
+
Dual-licensed under **MIT OR Apache-2.0**.
|
package/package.json
CHANGED
|
Binary file
|
package/sekejap.darwin-x64.node
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|