@atscript/moost-db
v0.1.50
Published
Generic database controller for Moost with Atscript.
Maintainers
Readme
Generic database controller for the Moost framework. Exposes Atscript-defined database tables and views as RESTful HTTP endpoints with zero boilerplate. Works with any @atscript/db adapter (SQLite, PostgreSQL, MongoDB, MySQL).
Installation
pnpm add @atscript/moost-dbPeer dependencies: moost, @moostjs/event-http, @atscript/db, @atscript/typescript.
Quick Start
import { AsDbController, TableController } from "@atscript/moost-db";
import { User } from "./models/user.as";
@TableController(usersTable)
export class UsersController extends AsDbController<typeof User> {}This gives you: GET /query, GET /pages, GET /one/:id, POST /, PUT /, PATCH /, DELETE /:id, GET /meta.
Features
- Full CRUD via
AsDbController— insert, replace, update, delete (single and batch) - Read-only via
AsDbReadableController— query, paginate, get-one for views - URL query syntax — filtering, sorting, pagination, field selection via query strings
- Relation loading with
$with— eagerly load related data - Text search (
$search) and vector search ($vector) with pluggablecomputeEmbedding()hook - Aggregation with
$groupBy - Overridable hooks —
onWrite,onRemove,transformFilter,computeEmbedding - Decorator shortcuts:
@TableController,@ReadableController,@ViewController
Documentation
License
MIT
