| field | Description | Example |
|---|---|---|
| <MODEL_NAME>Model | Database model instance declared in model.document.ts | |
| logger | Built-in logger module for stdout logging | |
Database model instance declared in model.document.ts
Built-in logger module for stdout logging
| method | Description | Example |
|---|---|---|
| getProduct(id: string) | Load document by ID. Throws error if not found. | |
| loadProduct(id?: string) | Load document by ID. Returns null if not found. | |
| loadProductMany(ids: string[]) | Batch load documents by IDs. Returns array of docs or nulls. | |
| createProduct(data: db.ProductInput) | Create a new document with input data. | |
| updateProduct(id: string, data: Partial<db.Product>) | Update document by ID. Returns updated document. | |
| removeProduct(id: string) | Soft-delete document by ID. Sets status to 'archived'. | |
| searchProduct(searchText: string, queryOption?: ListQueryOption) | Search documents by text. Returns docs and count. | |
| searchDocsProduct(searchText: string, queryOption?: ListQueryOption) | Search documents by text. Returns docs only. | |
| searchCountProduct(searchText: string) | Count documents matching search text. | |
Load document by ID. Throws error if not found.
Load document by ID. Returns null if not found.
Batch load documents by IDs. Returns array of docs or nulls.
Create a new document with input data.
Update document by ID. Returns updated document.
Soft-delete document by ID. Sets status to 'archived'.
Search documents by text. Returns docs and count.
Search documents by text. Returns docs only.
Count documents matching search text.
| method | Description | Example |
|---|---|---|
| list<Query>(...args, option?) | List documents matching defined query. | |
| listIds<Query>(...args, option?) | List document IDs matching defined query. | |
| find<Query>(...args, option?) | Find single document matching defined query. | |
| findId<Query>(...args, option?) | Find single document ID matching defined query. | |
| pick<Query>(...args, option?) | Find single document matching query. Throws if not found. | |
| pickId<Query>(...args, option?) | Find single document ID matching query. Throws if not found. | |
| exists<Query>(...args) | Check if document exists matching defined query. Returns ID or null. | |
| count<Query>(...args) | Count documents matching defined query. | |
| insight<Query>(...args) | Get aggregated statistics matching defined query. | |
| query<Query>(...args) | Get the raw query object defined in Filter. | |
List documents matching defined query.
List document IDs matching defined query.
Find single document matching defined query.
Find single document ID matching defined query.
Find single document matching query. Throws if not found.
Find single document ID matching query. Throws if not found.
Check if document exists matching defined query. Returns ID or null.
Count documents matching defined query.
Get aggregated statistics matching defined query.
Get the raw query object defined in Filter.
| method | Description | Example |
|---|---|---|
| _preCreate(data) | Hook called before creation. Return modified data. | |
| _postCreate(doc) | Hook called after creation. Return modified doc. | |
| _preUpdate(id, data) | Hook called before update. | |
| _postUpdate(doc) | Hook called after update. | |
| _preRemove(id) | Hook called before removal. | |
| _postRemove(doc) | Hook called after removal. | |
| listenPre(type, listener) | Register dynamic pre-hook listener. | |
| listenPost(type, listener) | Register dynamic post-hook listener. | |
Hook called before creation. Return modified data.
Hook called after creation. Return modified doc.
Hook called before update.
Hook called after update.
Hook called before removal.
Hook called after removal.
Register dynamic pre-hook listener.
Register dynamic post-hook listener.
| method | Description | Example |
|---|---|---|
| service<T>() | Inject other services. | |
| use<T>() | Inject external classes or variables. | |
| env<T>(key, factory?) | Inject environment variable. Throws if missing. | |
| envOptional<T>(key, factory?) | Inject environment variable safely. Returns undefined if missing. | |
| generate<T>(factory) | Generate a value dynamically based on environment. | |
| signal<T>() | Inject signal (Websocket/Queue) module. | |
Inject other services.
Inject external classes or variables.
Inject environment variable. Throws if missing.
Inject environment variable safely. Returns undefined if missing.
Generate a value dynamically based on environment.
Inject signal (Websocket/Queue) module.