| method | Description | Example |
|---|---|---|
| .arg(name, Type, options?) | Required parameter. Options include { ref, renderOption } for UI rendering in admin panels. | |
| .opt(name, Type, options?) | Optional parameter. Value will be undefined if not provided. Use conditional spread in query. | |
| .query((...args) => MongoQuery) | Returns MongoDB query object. Arguments match the order of .arg() and .opt() calls. | |
Required parameter. Options include { ref, renderOption } for UI rendering in admin panels.
Optional parameter. Value will be undefined if not provided. Use conditional spread in query.
Returns MongoDB query object. Arguments match the order of .arg() and .opt() calls.
| method | Description | Example |
|---|---|---|
| this.set(data) | Set multiple fields at once. Equivalent to Object.assign(this, data) | |
| await this.save() | Persist changes to MongoDB. Returns the saved document. | |
| await this.refresh() | Reload document from database, discarding local changes. | |
Set multiple fields at once. Equivalent to Object.assign(this, data)
Persist changes to MongoDB. Returns the saved document.
Reload document from database, discarding local changes.
| 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 |
|---|---|---|
| byField(field) | Single doc by unique field | |
| byArrayField(field) | Multiple docs by field value | |
| byQuery([fields]) | Doc by multiple field conditions | |
Single doc by unique field
Multiple docs by field value
Doc by multiple field conditions