Skip to content

About

AQL, the AntelopeJS database query builder. Write a typed query once and run it on the database module your project loads.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

2 watching

Forks

Latest commit

 

History

83 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@antelopejs/interface-database

npm License Discord Docs

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.

What it offers

  • Schema declares tables, fields and indexes. Each schema can hold several isolated instances.
  • Table, Selection and SingleSelection insert, read, update and delete documents.
  • Stream filters, maps, joins, groups and aggregates. ValueProxy builds the expressions inside them.
  • changes() streams inserts, updates and deletions as they happen.
  • Queries are lazy. Nothing runs until you await a query, call .run() or iterate it.

Implementations

Module Notes
@antelopejs/mongodb MongoDB. Also implements @antelopejs/interface-mongodb.
@antelopejs/rethinkdb RethinkDB. Also implements @antelopejs/interface-rethinkdb.

Install

Add the interface to the module that runs queries:

pnpm add @antelopejs/interface-database

Then add an implementation to the project:

ajs project modules add @antelopejs/mongodb

Quick start

import { 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.

Documentation

Compatibility

The package declares this @antelopejs/* peer dependency:

Package Supported Tested with
@antelopejs/interface-core >=0.2.4 <1.0.0 0.2.4

Contributing

Read CONTRIBUTING.md before you open a pull request. The local checks are:

pnpm install
pnpm lint
pnpm test

License

Apache-2.0

About

AQL, the AntelopeJS database query builder. Write a typed query once and run it on the database module your project loads.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages