Registry / database / durable-objects-nosql

durable-objects-nosql

JSON →
library0.0.1jsnpmunverified

Provides a MongoDB-style NoSQL interface backed by Cloudflare Workers Durable Objects using SQLite storage. Version 0.0.1, early-stage. Differentiates by offering a familiar MongoDB-like API (find, insert, update, delete) for Durable Objects, simplifying state management in edge workers. Enables schema-less document storage with indexing support, leveraging Cloudflare's distributed execution model.

npm install durable-objects-nosql
INSTALL
IMPORT
SIG · DURABLE-OBJECTS-NO
D
durable-objects-nosql
databasejavascriptv0.0.1
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.

DurableObjectNosql
✓ import { DurableObjectNosql } from 'durable-objects-nosql'
Named export for the base class to extend your Durable Object from.
Collection
✓ import { Collection } from 'durable-objects-nosql'
✗ import { MongoCollection } from 'durable-objects-nosql'
The collection wrapper is named Collection, not MongoCollection.
createServer
✓ import { createServer } from 'durable-objects-nosql'
Helper to bootstrap a Durable Object endpoint; only for Workers environment.

Shows how to define a Durable Object class with a MongoDB-like collection, create an index, insert and query a document.

import { DurableObjectNosql, Collection } from 'durable-objects-nosql'; interface User { id: string; name: string; email: string; } class UserStorage extends DurableObjectNosql { async initialize() { const users = new Collection<User>(this, 'users'); await users.createIndex({ email: 1 }, { unique: true }); await users.insertOne({ id: '1', name: 'Alice', email: 'alice@example.com' }); const result = await users.findOne({ email: 'alice@example.com' }); return result; } } export { UserStorage }; export default { fetch: (request: Request, env: Env) => { /* handle */ } };
Debug
Known issues
gotchaDurable Object storage is per-object; don't assume cross-object queries.
fix
Use a single Durable Object class per collection or implement custom routing.
affects: >=0.0.0
breakingAlpha version: API may change without notice.
fix
Pin to exact version and review changelog before upgrades.
affects: 0.0.x
gotchaMethods like findOne return plain objects; they must be used with `await`.
fix
Always await asynchronous operations to avoid undefined results.
affects: >=0.0.0
gotchaIndex creation is asynchronous; ensure indexes are created before queries.
fix
Call createIndex in the class constructor or an init method called on first request.
affects: >=0.0.0
deprecatedThe `updateMany` method signature changed; now requires filter and update object.
fix
Use `collection.updateMany({ filter }, { $set: {...} })` matching MongoDB syntax.
affects: <=0.0.1
Errors
Common errors & fixes
Error: Cannot find module 'durable-objects-nosql'
Package not installed or import path incorrect.
fix
Run `npm install durable-objects-nosql` and ensure import path is correct (no typo).
TypeError: collection.findOne is not a function
Collection may not have been instantiated correctly or import used wrongly.
fix
Ensure you import Collection as named export: `import { Collection } from 'durable-objects-nosql'`.
Error: Durable Object storage not available outside of Worker
Trying to use Durable Object methods outside of Cloudflare Workers environment.
fix
Run code only inside a Cloudflare Worker with proper bindings.
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
durable-objects-nosql — npm install durable-objects-nosql · libregistry