@dalgo/core
v0.1.0
Published
Database abstraction layer for TypeScript and browser applications
Downloads
437
Readme
DALgo for TypeScript
@dalgo/core is the browser-neutral TypeScript implementation of
DALgo. It provides hierarchical keys, typed collections,
structured queries, records, database sessions, and transaction-only mutation
contracts without coupling application code to a database SDK.
The first adapter is the
Firestore adapter,
which uses Firebase's modular Web SDK and therefore works directly in browsers.
The adapters are being migrated to the @dalgo/* scope separately; the
@dalgo/core package does not connect to a database by itself.
Install
Once the first npm release is available:
pnpm add @dalgo/coreFor source development before or after publication, use the
dalgo-js repository. Do not mix this
package with an adapter still importing @dal-go/dalgo: that would install
two different DALgo core module identities.
Build a browser query
import { collection, key } from "@dalgo/core";
interface Item {
title: string;
done: boolean;
rank: number;
}
const spaceKey = key("spaces", spaceId);
const items = collection<Item>("items").in(spaceKey);
const query = items.query()
.where("done", "==", false)
.orderBy("rank")
.limit(25)
.build();
// Pass query to an adapter updated for @dalgo/core.Subcollections use DALgo's ordinary parent-key model:
import { collection, key } from "@dalgo/core";
const spaceKey = key("spaces", spaceId);
const items = collection<Item>("items").in(spaceKey);Collection-group queries are explicit:
import { collectionGroup } from "@dalgo/core";
const query = collectionGroup<Item>("items")
.where("done", "==", false)
.limit(25)
.build();Security boundary
DALgo does not turn browser code into a trusted backend. A Firestore browser request runs as the current Firebase user and is authorized by Firestore Security Rules. Use Firebase Authentication, least-privilege rules, and App Check where appropriate. Never put service-account credentials in a browser.
Status
The initial API covers point reads, hierarchical collections, collection-group queries, filters, ordering, deterministic cursor pagination, and read-write transactions. Adapters must reject unsupported capabilities explicitly rather than silently changing query semantics.
License
MIT
