Skip to content

Library for interaction with component api and functionalities.

Component

v2(ref) : ComponentV2 method

get v2 library interface ex: component.v2('users')


ComponentV2

new(ref) : ComponentV2 method

create new reference to the component by name, tag or uuid


find(payload Filters) : Pagination method

find the models inside the component using the filters


get(uuid) : Model method

get component model by uuid


update(uuid, data) : any method


concurrentUpdate(uuid, version, data) : any method

concurrently update model. This will throw an error if something else updated the model in the meantime.


create(data) : any method

create new component model with provided data


delete(uuid) : any method

delete component model by uuid


aggregate(payload) : any method

use aggregation pipeline syntax to get aggregated results


workflow(event, input) method

trigger custom event in the components workflow and provide custom input


Types

Pagination

{
    items: [],
    total: 0,
    pages: 0,
    page: 1
}

Filters

{
    currentPage: 1,
    perPage: 50,
    sortDesc: 1 || -1,
    filterOn: [],
    filter '',
    dateFrom: '2022-06-22',
    dateTo: '2023-06-22',
    dateField: 'created_at'
    $adv: Query
    $aggregate: Pipeline
}

Query

Pipeline

Date Comparisons

When comparing date fields (e.g. created_at, updated_at, or custom date fields), $adv and $aggregate handle dates differently.

$adv

Both plain date strings and $date casting are supported. Plain date strings are automatically detected and converted to proper dates.

{
    "$adv": [{ "updated_at": { "$lt": "2025-01-01" } }]
}
{
    "$adv": [{ "updated_at": { "$lt": { "$date": "2025-01-01" } } }]
}

Supported date formats: ISO 8601 (2025-01-01T00:00:00Z), date-only (2025-01-01), datetime (2025-01-01 00:00:00).

$aggregate

In aggregation pipelines, you must use $date to cast date values. Plain date strings will be treated as strings and comparisons will not work correctly.

{
    "$aggregate": [
        { "$match": { "updated_at": { "$gte": { "$date": "2025-01-01T00:00:00Z" } } } }
    ]
}

Warning

When using $aggregate, always wrap date values with $date. Without it, dates are compared as strings and will produce incorrect results. Without $date, date comparisons will behave as string comparisons and may return unexpected results.