Registry / database / cojson-storage-do-sqlite

cojson-storage-do-sqlite

JSON →
library0.20.18jsnpmunverified

Persistence layer for CoJSON/Jazz (jazz.tools) using Cloudflare Durable Objects SQLite storage. Current version 0.20.18, released as part of the Jazz monorepo. Designed specifically for Cloudflare Workers environments, leveraging Durable Objects for transactional SQLite access. Ships TypeScript types. Peer dependency on @cloudflare/workers-types. Suitable for serverless applications requiring real-time collaboration and offline support via the Jazz framework.

npm install cojson-storage-do-sqlite
INSTALL
IMPORT
SIG · COJSON-STORAGE-DO-
C
cojson-storage-do-sqlite
databasejavascriptv0.20.18
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createInstance
import { createInstance } from 'cojson-storage-do-sqlite'
const createInstance = require('cojson-storage-do-sqlite')
Package is ESM only. Use named import.
CojsonStorageDoSqlite
import type { CojsonStorageDoSqlite } from 'cojson-storage-do-sqlite'
import { CojsonStorageDoSqlite } from 'cojson-storage-do-sqlite'
CojsonStorageDoSqlite is a class exported as a type; for runtime usage you need the default export or other named exports. Use type import to avoid bundling issues.
default
import CojsonStorageDoSqlite from 'cojson-storage-do-sqlite'
import { default as CojsonStorageDoSqlite } from 'cojson-storage-do-sqlite'
Default export is the main class. Named default import is unnecessary.

Shows how to instantiate CojsonStorageDoSqlite inside a Cloudflare Durable Object, using the DurableObjectStorage from the constructor.

import CojsonStorageDoSqlite from 'cojson-storage-do-sqlite'; // In your Durable Object class export class MyDO { private storage: DurableObjectStorage; constructor(ctx: DurableObjectState, env: Env) { this.storage = ctx.storage; } async fetch(request: Request): Promise<Response> { const store = new CojsonStorageDoSqlite(this.storage); // Use store methods... return new Response('OK'); } }
Debug
Known issues
gotchaOnly works with Durable Objects SQLite storage; other storage backends will break.
fix
Ensure you have enabled SQLite storage in your wrangler.toml: [durable_objects] bindings = [{ name = "MY_DO", class_name = "MyDO" }] and set sqlite = true in the DO's migration.
affects: >=0.0.0
breakingIn v0.20.0, the constructor signature changed from (storage, options?) to (storage).
fix
Remove second argument if any; pass all options via storage's own scoping.
affects: >=0.20.0
deprecatedThe old default export 'CojsonStorageDoSqlite' is deprecated in favor of 'createInstance' factory function.
fix
Use createInstance(storage) instead of new CojsonStorageDoSqlite(storage).
affects: >=0.19.0 <0.20.0
Errors
Common errors & fixes
TypeError: DurableObjectStorage is not a constructor
Using CojsonStorageDoSqlite outside of a Durable Object context, or forgetting to pass ctx.storage.
fix
Ensure you instantiate inside a Durable Object class and pass ctx.storage (the DurableObjectState's storage property).
Cannot find module 'cojson-storage-do-sqlite' or its corresponding type declarations
Package not installed or not compatible with tsconfig (missing moduleResolution: bundler or node16).
fix
Run npm install cojson-storage-do-sqlite, and ensure tsconfig.json has "moduleResolution": "bundler" or "node16" and "module": "esnext".
Error: No SQLite storage available. You may need to enable durable_objects and sqlite in wrangler.toml.
Durable Object not configured with SQLite.
fix
Add sqlite = true in the [durable_objects] migrations in wrangler.toml.
Upgrade
Version history
0.20.18latest on npm
Audit
Dependencies
@cloudflare/workers-typesoptionalRequired for TypeScript typings when running in Cloudflare Workers environment
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
cojson-storage-do-sqlite — npm install cojson-storage-do-sqlite · libregistry