@atscript/moost-db 0.1.38 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -0
- package/dist/index.cjs +329 -317
- package/dist/index.d.cts +204 -0
- package/dist/index.d.mts +204 -0
- package/dist/index.mjs +263 -228
- package/package.json +21 -14
- package/LICENSE +0 -21
- package/dist/index.d.ts +0 -200
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://atscript.dev/logo.svg" alt="Atscript" width="120" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">@atscript/moost-db</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Define your models once</strong> — get TypeScript types, runtime validation, and DB metadata from a single <code>.as</code> model.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://db.atscript.dev">Documentation</a> · <a href="https://db.atscript.dev/http/">HTTP API Guide</a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
Generic database controller for the [Moost](https://moost.org) 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).
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add @atscript/moost-db
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Peer dependencies: `moost`, `@moostjs/event-http`, `@atscript/db`, `@atscript/typescript`.
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { AsDbController, TableController } from "@atscript/moost-db";
|
|
31
|
+
import { User } from "./models/user.as";
|
|
32
|
+
|
|
33
|
+
@TableController(usersTable)
|
|
34
|
+
export class UsersController extends AsDbController<typeof User> {}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This gives you: `GET /query`, `GET /pages`, `GET /one/:id`, `POST /`, `PUT /`, `PATCH /`, `DELETE /:id`, `GET /meta`.
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- **Full CRUD** via `AsDbController` — insert, replace, update, delete (single and batch)
|
|
42
|
+
- **Read-only** via `AsDbReadableController` — query, paginate, get-one for views
|
|
43
|
+
- **URL query syntax** — filtering, sorting, pagination, field selection via query strings
|
|
44
|
+
- **Relation loading** with `$with` — eagerly load related data
|
|
45
|
+
- **Text search** (`$search`) and **vector search** (`$vector`) with pluggable `computeEmbedding()` hook
|
|
46
|
+
- **Aggregation** with `$groupBy`
|
|
47
|
+
- **Overridable hooks** — `onWrite`, `onRemove`, `transformFilter`, `computeEmbedding`
|
|
48
|
+
- Decorator shortcuts: `@TableController`, `@ReadableController`, `@ViewController`
|
|
49
|
+
|
|
50
|
+
## Documentation
|
|
51
|
+
|
|
52
|
+
- [HTTP API Guide](https://db.atscript.dev/http/)
|
|
53
|
+
- [Full Documentation](https://db.atscript.dev)
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|