AQL, the AntelopeJS database query builder. Write a typed query once and run it on the database module your project loads.
Documentation · Implementations · All interfaces and providers
AQL (Antelope Query Language) is the database-agnostic query builder of AntelopeJS. You write a chainable, typed query once, and any database module that implements the interface runs it.
Schemadeclares tables, fields and indexes. Each schema can hold several isolated instances.Table,SelectionandSingleSelectioninsert, read, update and delete documents.Streamfilters, maps, joins, groups and aggregates.ValueProxybuilds the expressions inside them.changes()streams inserts, updates and deletions as they happen.- Queries are lazy. Nothing runs until you
awaita query, call.run()or iterate it.
| Module | Notes |
|---|---|
@antelopejs/mongodb |
MongoDB. Also implements @antelopejs/interface-mongodb. |
@antelopejs/rethinkdb |
RethinkDB. Also implements @antelopejs/interface-rethinkdb. |
Add the interface to the module that runs queries:
pnpm add @antelopejs/interface-databaseThen add an implementation to the project:
ajs project modules add @antelopejs/mongodbimport { Schema } from "@antelopejs/interface-database";
interface Novel {
_id?: string;
title: string;
pageCount: number;
}
const schema = new Schema<{ novels: Novel }>("library", {
novels: {
fields: { title: "string", pageCount: "number" },
indexes: { pageCount: {} },
},
});
const novels = schema.instance().table("novels");
export async function addNovel(title: string, pageCount: number) {
return await novels.insert({ title, pageCount });
}
export async function listLongNovels() {
return await novels
.filter((novel) => novel.key("pageCount").ge(300))
.orderBy("pageCount", "desc");
}Callbacks such as the filter above receive a ValueProxy, not a document. The callback runs once, when the query is built, and the query records only the ValueProxy calls it makes.
The package declares this @antelopejs/* peer dependency:
| Package | Supported | Tested with |
|---|---|---|
@antelopejs/interface-core |
>=0.2.4 <1.0.0 |
0.4.0 |
Read CONTRIBUTING.md before you open a pull request. The local checks are:
pnpm install
pnpm lint
pnpm testAntelopeJS is a TypeScript framework where modules depend on contracts and the application chooses the provider behind each one. AntelopeJS DMS, the open-source back office, is built on it.
| Area | Contracts | Providers |
|---|---|---|
| API | interface-api · interface-api-util · interface-data-api |
api |
| Auth | interface-auth |
auth-jwt |
| Database | interface-database · interface-database-decorators · interface-database-catalog · interface-mongodb · interface-rethinkdb |
postgres · mongodb · rethinkdb |
| Redis | interface-redis · interface-redis-scheduler |
redis |
interface-email |
nodemailer · brevo |
|
| File storage | interface-file-storage |
file-storage-local · file-storage-s3 |
| Payments | interface-payment · interface-subscriptions · interface-stripe |
stripe · mollie · checkout-com · payment-subscriptions |