Complete reference for all JSNOSLQC interfaces. All operations are async and return Promises unless stated otherwise.
Static registry that routes connection requests to registered drivers.
Returns a Client from the first registered driver that accepts the URL.
import { DriverManager } from '@alt-javascript/jsnosqlc-core';
const client = await DriverManager.getClient('jsnosqlc:memory:');
const client = await DriverManager.getClient('jsnosqlc:mongodb://localhost:27017/mydb');
const client = await DriverManager.getClient('jsnosqlc:dynamodb:us-east-1', {
endpoint: 'http://localhost:8000',
credentials: { accessKeyId: 'local', secretAccessKey: 'local' },
});Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
url |
string |
Yes | A jsnosqlc: URL |
properties |
Object |
No | Driver-specific connection properties |
Throws: Error if no registered driver accepts the URL.
Register a driver instance. Drivers self-register on import — manual registration is only needed in tests.
Remove a previously registered driver.
Remove all registered drivers. Useful for test isolation.
Return a shallow copy of the registered drivers array.
Convenience factory that encapsulates connection configuration. Mirrors the DataSource pattern from jsdbc.
import { ClientDataSource } from '@alt-javascript/jsnosqlc-core';
import '@alt-javascript/jsnosqlc-memory';
const ds = new ClientDataSource({ url: 'jsnosqlc:memory:' });
const client = await ds.getClient();| Property | Type | Required | Description |
|---|---|---|---|
url |
string |
Yes | jsnosqlc URL |
username |
string |
No | Passed to driver as a property |
password |
string |
No | Passed to driver as a property |
properties |
Object |
No | Additional driver-specific properties |
Returns Promise<Client>. Calls DriverManager.getClient(url, properties).
Represents a session with a database. Obtained from DriverManager.getClient() or ClientDataSource.getClient().
Returns a Collection for the named collection. Returns a cached instance on subsequent calls with the same name.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | Collection name |
Throws: Error if the client is closed.
Returns Promise<void>. Closes the client, clears the collection cache, and releases underlying resources.
Returns boolean. true after close() has been called.
Returns the jsnosqlc: URL string this client was opened with.
Represents a named collection, table, or bucket. Obtained via client.getCollection(name).
Returns Promise<Object|null>. Retrieve a document by its primary key. Returns null if no document exists for the key.
const doc = await col.get('order-001');
if (doc === null) console.log('Not found');Returns Promise<void>. Upsert a document under the given key. Creates a new document or replaces an existing one entirely.
await col.store('order-001', { customerId: 'c1', total: 59.99, status: 'pending' });Returns Promise<void>. Delete a document by its primary key. No-op if the document does not exist.
await col.delete('order-001');Returns Promise<string>. Insert a document and let the backend assign a unique key. Returns the assigned key (a string in all drivers).
const id = await col.insert({ customerId: 'c2', total: 120.00, status: 'new' });
const doc = await col.get(id);The assigned id is also set as doc._id in the stored document.
Returns Promise<void>. Partially update an existing document. Only the fields present in patch are updated; all other fields are preserved.
await col.update('order-001', { status: 'shipped' });
// 'customerId' and 'total' are unchangedThrows: Error if no document exists for the key.
Returns Promise<Cursor>. Query the collection using a filter built with the Filter builder.
const filter = Filter.where('status').eq('pending').build();
const cursor = await col.find(filter);Pass null or an empty filter AST to retrieve all documents:
const cursor = await col.find(null);
const all = cursor.getDocuments();Returns the collection name string.
Holds the results of a find() call. Supports cursor-style iteration, bulk access, and the async iterator protocol.
Returns Promise<boolean>. Advance to the next document. Returns true if there is a document at the new position, false when exhausted.
Returns Object. Return the document at the current cursor position. Must be called after a successful cursor.next().
Throws: Error if not on a valid position.
Returns Object[]. Return all documents as a plain array without cursor iteration. Does not affect cursor position.
const docs = cursor.getDocuments(); // returns all results immediatelyReturns Promise<void>. Releases cursor resources. Called automatically by the async iterator.
Returns boolean.
Cursors implement Symbol.asyncIterator:
for await (const doc of cursor) {
console.log(doc);
}
// cursor is closed automatically on exhaustionChainable builder that constructs a filter AST. The AST is consumed by driver translators to produce native query expressions.
Static factory. Start a new filter on the given field. Returns a FieldCondition.
Filter.where('age').gt(18).and('status').eq('active').build()Static factory. Combine two or more built filter ASTs into an OR compound. Each argument should be a built AST (the return value of .build() or .not()).
const or = Filter.or(
Filter.where('status').eq('active').build(),
Filter.where('status').eq('pending').build()
);
// { type: 'or', conditions: [...] }Chain an additional AND condition. Returns a FieldCondition bound to the same filter.
Negate the current filter. Calls build() internally and wraps the result.
const notActive = Filter.where('status').eq('inactive').not();
// { type: 'not', condition: { type: 'condition', field: 'status', op: 'eq', value: 'inactive' } }Produce the filter AST. Returns a single condition node for single-condition filters, or an { type: 'and', conditions: [...] } node for multi-condition filters.
Filter.where(field) and filter.and(field) return a FieldCondition. Call an operator method to add the condition and return the parent Filter.
| Method | Operator | Description |
|---|---|---|
.eq(value) |
eq |
Equal |
.ne(value) |
ne |
Not equal |
.gt(value) |
gt |
Greater than |
.gte(value) |
gte |
Greater than or equal |
.lt(value) |
lt |
Less than |
.lte(value) |
lte |
Less than or equal |
.contains(value) |
contains |
Array element match or string substring |
.in(values) |
in |
Field is one of the values (array) |
.nin(values) |
nin |
Field is not one of the values (array) |
.exists(bool) |
exists |
Field is present (true) or absent (false) |
The internal representation passed to driver translators.
{ type: 'condition', field: 'age', op: 'gt', value: 18 }{ type: 'and', conditions: [
{ type: 'condition', field: 'age', op: 'gt', value: 18 },
{ type: 'condition', field: 'status', op: 'eq', value: 'active' }
]}{ type: 'or', conditions: [
{ type: 'condition', field: 'status', op: 'eq', value: 'active' },
{ type: 'condition', field: 'status', op: 'eq', value: 'pending' }
]}{ type: 'not', condition: { type: 'condition', field: 'status', op: 'eq', value: 'inactive' } }jsnosqlc:<subprotocol>:<connection-details>
| URL | Driver Package |
|---|---|
jsnosqlc:memory: |
@alt-javascript/jsnosqlc-memory |
jsnosqlc:localstorage: |
@alt-javascript/jsnosqlc-localstorage |
jsnosqlc:sessionstorage: |
@alt-javascript/jsnosqlc-localstorage |
jsnosqlc:mongodb://<host>:<port>/<db> |
@alt-javascript/jsnosqlc-mongodb |
jsnosqlc:dynamodb:<region> |
@alt-javascript/jsnosqlc-dynamodb |
jsnosqlc:firestore:<project-id> |
@alt-javascript/jsnosqlc-firestore |
jsnosqlc:cosmosdb:local |
@alt-javascript/jsnosqlc-cosmosdb |
jsnosqlc:cosmosdb:<https-endpoint> |
@alt-javascript/jsnosqlc-cosmosdb |
jsnosqlc:redis://<host>:<port>[/<db>] |
@alt-javascript/jsnosqlc-redis |
jsnosqlc:cassandra:<host>:<port>/<keyspace> |
@alt-javascript/jsnosqlc-cassandra |
Implements the full Collection interface over the Web Storage API. Supports both localStorage (persistent) and sessionStorage (tab-scoped). Works in the browser via an ESM bundle and in Node.js via an injected MockStorage.
npm install @alt-javascript/jsnosqlc-core @alt-javascript/jsnosqlc-localstorage| URL | Backend |
|---|---|
jsnosqlc:localstorage: |
globalThis.localStorage (browser) or storageBackend (injected) |
jsnosqlc:sessionstorage: |
globalThis.sessionStorage (browser) or storageBackend (injected) |
| Property | Type | Description |
|---|---|---|
storageBackend |
Storage |
Optional. Any Web Storage-compatible object. Defaults to globalThis.localStorage / globalThis.sessionStorage. Pass a MockStorage instance for Node.js testing. |
import { DriverManager, MockStorage } from '@alt-javascript/jsnosqlc-localstorage';
const client = await DriverManager.getClient('jsnosqlc:localstorage:', {
storageBackend: new MockStorage(),
});
const col = client.getCollection('orders');
await col.store('o1', { status: 'pending', total: 59.99 });<script type="module">
import { DriverManager, Filter } from
'https://unpkg.com/@alt-javascript/jsnosqlc-localstorage/dist/jsnosqlc-localstorage.esm.js';
const client = await DriverManager.getClient('jsnosqlc:localstorage:');
const col = client.getCollection('orders');
await col.store('o1', { status: 'pending', total: 59.99 });
</script>Keys are stored as <clientId>:<collectionName>:<docKey>. The clientId is generated per getClient() call, preventing cross-client data collision when multiple instances share the same storage backend.
find() iterates all storage keys with the collection prefix. Suitable for collections with hundreds to low-thousands of documents (within the browser's ~5–10 MB quota). Not suitable for large-scale data — use a server-side driver for that.
All six Collection operations: get, store, delete, insert, update, find.
All ten Filter operators + Filter.or() and .not() via MemoryFilterEvaluator.
In-memory implementation of the Web Storage API. Provided by @alt-javascript/jsnosqlc-localstorage for use in Node.js test environments.
import { MockStorage } from '@alt-javascript/jsnosqlc-localstorage';
const storage = new MockStorage();| Method | Description |
|---|---|
storage.getItem(key) |
Returns the string value for key, or null if absent |
storage.setItem(key, value) |
Stores String(value) under String(key) |
storage.removeItem(key) |
Removes key |
storage.clear() |
Removes all keys |
storage.length |
Number of stored keys |
storage.key(index) |
Returns the key at index (insertion order), or null |
MockStorage is compatible with any API that accepts a Web Storage object. It can also be used standalone in tests to inspect stored state:
const storage = new MockStorage();
const client = await DriverManager.getClient('jsnosqlc:localstorage:', {
storageBackend: storage,
});
await client.getCollection('users').store('u1', { name: 'Alice' });
// Inspect raw storage state
console.log(storage.length); // 1 — one namespaced key storedThrown when a Collection method is called that the underlying driver does not support.
import { UnsupportedOperationError } from '@alt-javascript/jsnosqlc-core';All six Collection operations are supported by all eight built-in drivers.