Версия:

get

The get method receives fetch conditions as input and returns a set of records in the rows array (res.data.rows). It works through the cache.

Input Parameters. IAPIQueryParams Interface

columns

columns?: string[]

An array of strings listing the columns that should be in the resulting response. The system will check for the existence of such fields in the profile and will not allow requesting a non-existent field or inserting an SQL expression.

where / param_where. Fetch Conditions

By default, there are no conditions (only the default limit is applied).

  1. A default_where can be defined for a class or client object, which is applied to all queries.
  2. where is an array of condition objects (IOneWhere). A condition can be either a direct comparison (field, type, value) or a group of conditions.

IOneWhere Interface:

export interface IOneWhere {
   key?: string,
   type?: string
   val1?: any
   val2?: any
   group?: string
   comparisonType?: string
   is_role?: boolean,
   role_group?: string
   name?: string // info
   isGroup?: boolean // if set, items must be an array
   items?: IOneWhere[]
   isOr?: boolean // Defines the comparison type with the previous element (OR for the entire group)
   binary?: boolean
   s?: string // sql string for one where or for all items (if isGroup)
}

Wrapper Functions: Implemented in \models\system\CoreClass\prepareWhere.ts. They simplify the creation of IOneWhere objects.

Usage Example of Groups:

const res = await r.api(User, 'get', {
    where: [
        whereEq('gender_sysname', 'MALE'),
        groupOr([
            whereEq('firstname', 'Alex'),
            whereEq('nickname', 'Alex')
        ])
    ]
})
if (res.code) return res
const users = res.data.rows
param_where

An obsolete form { [field: string]: any }. The comparison type is always =. Not recommended for use when wrapper functions are available.

limit | page_no | offset
sort

sort?: { columns: string[], directions?: string[] } | string | false Defines the sorting. By default, it’s taken from the Class profile (usually id DESC).

prepareSQL

prepareSQL?: boolean If true, the query is not executed but returned as an SQL string in res.data.sql. This is a queryBuilder that takes into account core specifics (joins, profiles, data types). Used for subsequent substitution in whereInSelect.

countOnly

countOnly?: boolean Returns only the number of records for the given conditions (ignoring limit) in res.data.count.

enableInheritValues

enableInheritValues: boolean For hierarchical entities, allows inheriting values from parents if no value is set (the field must have the is_inherit flag in the profile). An IInheritedValue object is returned instead of the value.

enableMultiValues

enableMultiValues: boolean For dynamic fields (one-to-many relationship).

co_path___

Passed automatically from client components. Used for the dynamic fields mechanism (e.g., product characteristics depending on the category) so that the core understands the query context and necessary additional fields.

group_by

group_by?: string | string[] Defines grouping by the specified fields. Usually used together with specColumns.

specColumns

specColumns?: { [alias: string]: string } Allows specifying SQL expressions or aggregation functions (e.g., sum(amount)). Important: This parameter is prohibited for client requests.


Output Parameters. IAPIResponse / IError Interface

In case of an error, an instance of MyError or UserError is returned.

Successful response (res.data):