cozodb_goja

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2026 License: MIT Imports: 0 Imported by: 0

README

cozodb-goja

cozodb-goja is an initial Go + goja implementation of the CozoDB JavaScript API contract described in ticket COJS-01-INITIAL-BUILD.

Status

  • Implemented core API domain layer in pkg/cozoapi:
    • exec, q, cq, atomic
    • relation compiler + helpers, including db.rel(name).put/insert/update/rm/del/get/columns/indices/access
    • query policy enforcement (limits/timeouts/system-op and relation restrictions)
  • Implemented native goja module adapter in pkg/cozoapi/module:
    • require("cozodb").open({ backend })
    • db handle methods: exec, q, cq, atomic, rel, export, import, close
  • Added fake backend + tests for deterministic behavior.
  • Added optional cozo_cgo adapter scaffold.

CLI

Run inline code:

GOWORK=off go run ./cmd/cozo --eval 'const db = require("cozodb").open(); db.backend'

Run a script file:

GOWORK=off go run ./cmd/cozo --script ./examples/demo.js

Start REPL:

GOWORK=off go run ./cmd/cozo

JavaScript usage

const cozo = require("cozodb");
const db = cozo.open({ backend: "fake" });

db.exec("?[x] <- [[1]]")
  .then((res) => {
    console.log(res.scalar());
  });

Prepared + atomic:

const q1 = db.cq`?[id] <- [[${"u1"}]]`;
const q2 = db.cq`?[id] <- [[${"u2"}]]`;

db.atomic([q1, q2]).then((res) => console.log(res.rows));

Relation helper:

const users = db.rel("users");
users.put([{ id: "u1", name: "Ada" }], { returning: true });

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
cozo command
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL