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.
Part of AntelopeJS. Used by AntelopeJS DMS, the open-source back office for your PostgreSQL, MongoDB or RethinkDB database.
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.2.4 |
Read CONTRIBUTING.md before you open a pull request. The local checks are:
pnpm install
pnpm lint
pnpm test