Skip to main content
Home
Works with
This package works with Node.js, Deno, Browsers
This package works with Node.js
This package works with Deno
This package works with Browsers
JSR Score100%
Downloads398/wk
Published8 months ago (0.3.1)

A distributed Version Control Database (VCDB) designed for edge-native applications

GoatDB: An Embedded, Distributed, Document Database

GoatDB is a real-time, version-controlled database for Deno, React, and low-friction deployments. It excels at real-time collaboration and embedded caching applications while prioritizing speed and developer experience.

Key Features:

  • No Dedicated Infra: Run the entire DB client-side, with incremental queries
  • Resilience & Offline-First: Clients keep working if server goes down
  • Edge-Native: Most processing happens in the client
  • Real-Time Collaboration: Built-in sync keeps state synchronized
  • Distributed Version Control: Leverages concepts from DVCS with bloom filter-based synchronization
  • Automatic Conflict Resolution: Uses ephemeral CRDTs for efficient real-time conflict resolution
  • Application-Level Sharding: Natural scalability for multi-user applications

Check out https://goatdb.dev for additional docs.

Examples

Example 1

import { GoatDB, DataRegistry } from '@goatdb/goatdb';

// Define a schema for tasks
const taskSchema = {
  ns: 'task',
  version: 1,
  fields: {
    text: {
      type: 'string',
      required: true,
    },
    done: {
      type: 'boolean',
      default: () => false,
    }
  }
} as const;

// Register the schema
DataRegistry.default.register(taskSchema);

// Initialize GoatDB with optional peers for replication
const db = new GoatDB({
  path: '/home/my-app',
  peers: ['http://10.0.0.1']
});

// Create a new task
await db.create('/data/user123', taskSchema, {
  text: 'Learn GoatDB'
});

// Query tasks
const query = db.query({
  source: '/data/user123',
  schema: taskSchema,
  // Find incomplete tasks
  predicate: ({ item }) => !item.get('done'),
  // Sort by text alphabetically
  sortDescriptor: ({ left, right }) =>
    left.get('text').localeCompare(right.get('text')),
  // Optional context passed to predicate and sort functions
  ctx: { showCompleted: false }
});

// Get live results that update automatically
const tasks = query.results();

// Listen for changes
query.onResultsChanged(() => {
  console.log('Tasks updated:', query.results());
});

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@goatdb/goatdb

Import symbol

import * as goatdb from "@goatdb/goatdb";
or

Import directly with a jsr specifier

import * as goatdb from "jsr:@goatdb/goatdb";

Add Package

pnpm i jsr:@goatdb/goatdb
or (using pnpm 10.8 or older)
pnpm dlx jsr add @goatdb/goatdb

Import symbol

import * as goatdb from "@goatdb/goatdb";

Add Package

yarn add jsr:@goatdb/goatdb
or (using Yarn 4.8 or older)
yarn dlx jsr add @goatdb/goatdb

Import symbol

import * as goatdb from "@goatdb/goatdb";

Add Package

vlt install jsr:@goatdb/goatdb

Import symbol

import * as goatdb from "@goatdb/goatdb";

Add Package

npx jsr add @goatdb/goatdb

Import symbol

import * as goatdb from "@goatdb/goatdb";