System Object Operation Interface

interface Setup {
    batchInsert: ((records) => string[]);
    batchUpdate: ((records) => string[]);
    count: ((condition?) => number);
    delete: ((id) => number);
    deleteByCondition: ((condition?) => number);
    insert: ((record) => string);
    query: ((id) => Record);
    queryByCondition: ((condition?, option?, relation?) => Record[]);
    update: ((id, record) => number);
    updateByCondition: ((record, condition?) => number);
}

Properties

batchInsert: ((records) => string[])

Inserting Records in Batches

Type declaration

    • (records): string[]
    • Parameters

      Returns string[]

Returns

ID set of records that are successfully inserted.

batchUpdate: ((records) => string[])

Batch Update Records

Type declaration

    • (records): string[]
    • Parameters

      Returns string[]

Returns

Updated record ID set

count: ((condition?) => number)

Count the number of records that meet the condition.

Type declaration

    • (condition?): number
    • Parameters

      • Optional condition: Condition

        Matching condition

      Returns number

Returns

Number of records that meet the conditions

Example


import * as db from 'db';

let s = db.setup('setup_object');
let cond = {
conjunction: db.Conjunction.AND,
conditions: [
{
field: "name",
"operator": db.Operator.eq,
"value": 'setup_name'
}
]
}
let num = s.count(cond);
delete: ((id) => number)

Deletes records by ID.

Type declaration

    • (id): number
    • Parameters

      • id: string

        Record ID.

      Returns number

Returns

Number of Affected Records

deleteByCondition: ((condition?) => number)

A maximum of 5000 records can be deleted based on conditions.

Type declaration

    • (condition?): number
    • Parameters

      Returns number

insert: ((record) => string)

Create a record

Type declaration

    • (record): string
    • Parameters

      Returns string

Returns

Specifies the ID of a new record.

query: ((id) => Record)

Querying Records by ID

Type declaration

Returns

Recording

queryByCondition: ((condition?, option?, relation?) => Record[])

The number of records to be returned can be limited. The skip value is used to specify the number of records to be returned. The limit value is used to specify the number of records to be returned.

If skip and limit are not specified, the default values are skip=0 and limit=5000, indicating that the first 5000 records in the result set are returned. The maximum limit can be set to 10000, indicating that the query interface can return only the first 10000 records in the query result set.

Type declaration

    • (condition?, option?, relation?): Record[]
    • Parameters

      • Optional condition: Condition

        Matching condition

      • Optional option: "db".Option

        Query Options

      • Optional relation: Relation

        Parent-son relationship

      Returns Record[]

Returns

Recordset

update: ((id, record) => number)

Updates records by ID.

Type declaration

    • (id, record): number
    • Parameters

      • id: string

        Record ID.

      • record: Record

        Update Content

      Returns number

Returns

Number of Affected Records

updateByCondition: ((record, condition?) => number)

Records are updated based on conditions. A maximum of 5000 records can be updated.

Type declaration

    • (record, condition?): number
    • Parameters

      • record: Record

        What needs to be updated

      • Optional condition: Condition

        Matching condition

      Returns number