Skip to main content

globals

SDK Type Declarations

API

DataModelMethods\<T>

Model Operation Methods Interface Definition.

Type Parameters

Model Operation Methods Interface Definition. | :------- | :--------------- | | T | Type of the model field. |

Properties

create()

create: (params) => Promise\<MethodResponse\<CreateResponse\<T>>>

Method for Creating a Single Record.

Example
models.<model_name>.create({
data: {
// Model Field Data
}
}).then(({ data }) => {
console.log(data.id); // Outputs the created data ID
});
Parameters
ParameterTypeDescription
paramsobjectContains the parameter object for creating data.
params.dataT-
params.envType?prod or preAccess production data or trial data
Returns

Promise\<MethodResponse\<CreateResponse\<T>>>

createMany()

createMany: (params) => Promise\<MethodResponse\<CreateManyResponse\<T>>>

Method for Creating Multiple Records.

Example
models.<model_name>.createMany({
data: [
// Model Field Data Array
]
}).then(({ data }) => {
console.log(data.idList); // Outputs the list of created data IDs
});
Parameters
ParameterTypeDescription
paramsobjectContains the parameter object for creating a data array.
params.dataT[]-
params.envType?prod or preAccess production data or trial data
Returns

Promise\<MethodResponse\<CreateManyResponse\<T>>>

delete()

delete: (params) => Promise\<MethodResponse\<DeleteResponse\<T>>>

Method for Deleting a Single Record.

Example
models.<model_name>.delete({
filter: {
where: {
// Filter conditions, e.g., delete specific records by ID
_id: {
$eq: "specific ID value"
}
}
}
}).then(({ data }) => {
console.log(data.count); // Outputs the number of deleted data records
});
Parameters
ParameterTypeDescription
paramsobjectContains the parameter object with filter conditions.
params.filterFilterParams\<T>-
params.envType?prod or preAccess production data or trial data
Returns

Promise\<MethodResponse\<DeleteResponse\<T>>>

deleteMany()

deleteMany: (params) => Promise\<MethodResponse\<DeleteManyResponse\<T>>>

Method for Deleting Multiple Records.

Example
models.<model_name>.deleteMany({
filter: {
where: {
// Filter conditions, e.g., delete all records meeting specific criteria
}
}
}).then(({ data }) => {
console.log(data.count); // Outputs the number of deleted data records
});
Parameters
ParameterTypeDescription
paramsobjectContains the parameter object with filter conditions.
params.filterFilterParams\<T>-
params.envType?prod or preAccess production data or trial data
Returns

Promise\<MethodResponse\<DeleteManyResponse\<T>>>

get()

get: (params) => Promise\<MethodResponse\<T>>

Method for obtaining a single record.

Example
models.<model_name>.get({
filter: {
where: {
// Filter conditions
}
},
select: {
$master: true // Select all fields of the primary table
}
}).then(({ data }) => {
console.log(data); // Output the queried data
});
Parameters
ParameterTypeDescription
paramsobjectContains the parameter object with filter conditions and selected fields.
params.filterFilterParams\<T>-
params.select?SelectParams\<T>-
params.envType?prod or preAccess production data or trial data
Returns

Promise\<MethodResponse\<T>>

list()

list: (params) => Promise\<MethodResponse\<object>>

Method for obtaining multiple records.

Example
models.<model_name>.list({
filter: {
where: {
// Filter conditions
}
},
select: {
$master: true // Select all fields of the primary table
},
getCount: true, // Enable to get total count.
pageSize: 10, // Page size
pageNumber: 1, // Current page number
orderBy: [{ createdAt: 'desc' }] // Sorting parameters
}).then(({ data }) => {
console.log(data.records, data.total); // Output the queried data records and total count
});
Parameters
ParameterTypeDescription
paramsobjectContains the parameter object with filter conditions, selected fields, pagination, and sorting options.
params.filter?FilterParams\<T>Filter conditions
params.getCount?booleanWhether to obtain the query count of filter matching conditions
params.orderBy?OrderByParams[]Sorting parameters. Currently supports sorting by up to 3 fields
params.pageNumber?numberPage number
params.pageSize?numberPage size. It is recommended to specify. If you need to set it to other values, it must be used together with pageNumber, and both must be specified to take effect.
params.select?SelectParams\<T>Specifies fields to return from the current table or related tables. To query all fields of the current table, use { $master: true }
params.envType?prod or preAccess production data or trial data
Returns

Promise\<MethodResponse\<object>>

update()

update: (params) => Promise\<MethodResponse\<UpdateResponse\<T>>>

Method for updating a single record.

Example
models.<model_name>.update({
data: {
// Updated data fields
},
filter: {
where: {
// Filter conditions
}
}
}).then(({ data }) => {
console.log(data.count); // Outputs the number of updated data records
});
Parameters
ParameterTypeDescription
paramsobjectContains the parameter object with update data and filter conditions.
params.dataT-
params.filterFilterParams\<T>-
params.envType?prod or preAccess production data or trial data
Returns

Promise\<MethodResponse\<UpdateResponse\<T>>>

updateMany()

updateMany: (params) => Promise\<MethodResponse\<CreateManyResponse\<T>>>

Method for updating multiple records.

Example
models.<model_name>.updateMany({
data: {
// Updated data fields
},
filter: {
where: {
// Filter conditions
}
}
}).then(({ data }) => {
console.log(data.count); // Outputs the number of updated data records
});
Parameters
ParameterTypeDescription
paramsobjectContains the parameter object with update data and filter conditions.
params.dataT-
params.filterFilterParams\<T>-
params.envType?prod or preAccess production data or trial data
Returns

Promise\<MethodResponse\<CreateManyResponse\<T>>>

upsert()

upsert: (params) => Promise\<MethodResponse\<UpsertResponse\<T>>>

Returns
Example
models.<model_name>.upsert({
update: {
// Updated data fields
},
create: {
// Created data fields
},
filter: {
where: {
// Filter conditions
}
}
}).then(({ data }) => {
console.log(data.count); // Outputs the number of updated data records
});
Parameters
ParameterTypeDescription
paramsobjectContains the parameter object with the create or update object and filter conditions.
params.createT-
params.filterFilterParams\<T>-
params.updateT-
params.envType?prod or preAccess production data or trial data
Returns

Promise\<MethodResponse\<UpsertResponse\<T>>>


Model

Basic Model type definition

Properties

_id?

optional _id: string

_openid?

optional _openid: string

createBy?

optional createBy: string

createdAt?

optional createdAt: number

owner?

optional owner: string

updateBy?

optional updateBy: string

updatedAt?

optional updatedAt: number

Type Alias

BasicComparisonOperator

BasicComparisonOperator: "$eq" | "$neq" | "$gt" | "$gte" | "$lt" | "$lte" | "$in" | "$nin"

Basic Comparison Operators type definition.


ComparisonOperator

ComparisonOperator: BasicComparisonOperator | SpecialComparisonOperator

Type definitions for comparison operators, including basic and special operators.

Example

$eq: equal;

CreateManyResponse\<T>

CreateManyResponse\<T>: object

Response type definition for creating multiple records.

Type Parameters

Model Operation Methods Interface Definition. | :------- | :--------------- | | T | Type of the model field. |

Type Declarations

idList

idList: string[]

List of IDs for the created records.


CreateResponse\<T>

CreateResponse\<T>: object

Return type definition for the data creation method.

Type Parameters

Model Operation Methods Interface Definition. | :------- | :--------------- | | T | Type of the model field. |

Type Declarations

id

id: string


DeleteManyResponse\<T>

DeleteManyResponse\<T>: UpdateResponse\<T>

Response type definition for deleting multiple records, same as that for update operations.

Type Parameters

Model Operation Methods Interface Definition. | :------- | :--------------- | | T | Type of the model field. |


DeleteResponse\<T>

DeleteResponse\<T>: object

Response type definition for delete operations, which indicates the number of records affected by the delete operation.

Type Parameters

Model Operation Methods Interface Definition. | :------- | :--------------- | | T | Type of the model field. |

Type Declarations

count

count: number

Number of records affected by the delete operation. If the count is 0, it means no records were deleted; If the count is greater than 0, it means that the corresponding number of records were successfully deleted.


FilterCondition

FilterCondition: { [key in ComparisonOperator]?: any }

Complex Query Condition Type Definition

Example

{
* "$eq": "val"
* }

FilterConditionItem\<T>

FilterConditionItem\<T>: { [key in keyof T]?: FilterCondition }

Filter Parameter Type Definition.

Complex Query Conditions Type Definition

Examples

Example 1: Use the $and operator to combine conditions, ensuring all conditions are met.

{
"$and": [
{
"key": {
"$eq": "val"
}
}
]
}

Example 2: Use the $and operator to combine conditions, including the $in operator to check array membership.

{
"$and": [
{
"key1": {
"$in": ["foo", "bar"]
}
},
{
"key2": {
"$in": [1, 2]
}
}
]
}

Type Parameters

Model Operation Methods Interface Definition. | :------- | :--------------- | | T | Type of the model field. |


FilterObject\<T>

FilterObject\<T>: { [operator in LogicalOperator]?: FilterConditionItem\<T>[] | FilterObject\<T> }

Definition of Filter Parameter Types.

Examples

{
"$and": [
{
"title": {
"$eq": "hello"
}
}
]
}
{
"$or": [
{
"$and": [
{
"title": {
"$eq": "hello"
}
},
{
"body": {
"$neq": "world"
}
}
]
},
{
"createdBy": {
"$eq": "xxx"
}
}
]
}

Type Parameters

Type ParametersDescription
T

Represents the type of the model field.

This type definition allows the use of complex query conditions to filter data.


FilterParams\<T>

FilterParams\<T>: object

Definition of Filter Parameter Types.

Example

{
relateWhere: {
comments: {
where: {
comment: {
$nempty: true,
},
},
},
},
where: {},
}

Type Parameters

Type ParametersDescription
TRepresents the type of the model field.

Type Declarations

relateWhere?

optional relateWhere: { [K in RelationKeys<T>]?: Object }

Relationship Query

where?

optional where: FilterConditionItem\<T> | FilterObject\<T>

Basic query


ListParams\<T>

ListParams\<T>: object

Definition of list Method Parameters.

Type Parameters

Model Operation Methods Interface Definition. | :------- | :--------------- | | T | Type of the model field. |

Type Declarations

filter?

optional filter: FilterParams\<T>

getCount?

optional getCount: boolean

orderBy?

optional orderBy: OrderByParams[]

pageNumber?

optional pageNumber: number

pageSize?

optional pageSize: number

relateWhere?

optional relateWhere: any

select?

optional select: SelectParams\<T> | object


ListResponse\<T>

ListResponse\<T>: MethodResponse\<object>

Return type definition for the data list method.

Type Declarations

records

records: T[]

total?

optional total: number

Type Parameters

Model Operation Methods Interface Definition. | :------- | :--------------- | | T | Type of the model field. |


LogicalOperator

LogicalOperator: "$and" | "$or"

Type definition for logical operators.


MethodResponse\<T>

MethodResponse\<T>: object

Return type definition for model operation methods.

Type Parameters

Model Operation Methods Interface Definition. | :------- | :--------------- | | T | Return data type. |

Type Declarations

data

data: T

returned data.

requestId?

optional requestId: string

unique identifier of the request.


OrderByParams

OrderByParams: object

Structure Definition of Sorting Parameters.

Example

{
"createdAt": "asc",
}

Index Signature

[key: string]: "asc" | "desc"


RelationField\<T>

RelationField\<T>: T extends object ? U : never

Type Parameters

Type Parameters
T

SelectParams\<T>

SelectParams\<T>: { [K in keyof T]?: T[K] extends (infer U)[] | undefined ? SelectParams\<U> | boolean : T[K] extends object | undefined ? SelectParams\<T[K]> | boolean : boolean } & object

Selection Parameter Structure Definition, used to specify the fields to be returned in queries.

Examples

{
"key1": true,
}
{
$master: true,
}
{
$master: true,
comments: {
comment: true,
}
}

Type Declarations

$master?

optional $master: boolean

Type Parameters

Model Operation Methods Interface Definition. | :------- | :--------------- | | T | Type of the model field. |


SpecialComparisonOperator

SpecialComparisonOperator: "$search" | "$nsearch" | "$empty" | "$nempty"

Interface Definition for Model Operation Methods.


UpdateResponse\<T>

UpdateResponse\<T>: object

Response type definition for update operations.

Type Parameters

Model Operation Methods Interface Definition. | :------- | :--------------- | | T | Type of the model field. |

Type Declarations

count

count: number

Number of records affected by the update operation.


UpsertResponse\<T>

UpsertResponse\<T>: object

Response type definition for create or update operations.

Type Parameters

Model Operation Methods Interface Definition. | :------- | :--------------- | | T | Type of the model field. |

Type Declarations

count

count: number

Number of changed records. A non-zero value indicates successful update.

id

id: string

Number of changed records. A non-empty value indicates successful creation.

OrmRawQueryClient

| T | Type of the model field. |

Properties

$runSQL()?

This method is supported only for server-side calls.

optional $runSQL: (sql, params?, config?) => Promise\<MethodResponse\<object>>

Parameters
ParameterTypeDescription
sqlstringsql statement
params?Record\<string, any>sql template variables
config?SQLCommandParamsConfiguration
Returns

Promise\<MethodResponse\<object>>

$runSQLRaw()?

This method is supported only for server-side calls.

optional $runSQLRaw: (sql, config?) => Promise\<MethodResponse\<object>>

Parameters
ParameterTypeDescription
sqlstringsql statement
config?SQLCommandParamsConfiguration
Returns

Promise\<MethodResponse\<object>>


SQLCommandParams

Properties

timeout?

optional timeout: number

Timeout period, defaults to 5s, with a maximum of 15s.

optional dbLinkName: string

The English identifier for the data connector, with the default value being the identifier for the MySQL database. When using a custom MySQL deployment, this must be changed.