Object wrapper

Hierarchy

  • Orm

Properties

batchInsert: ((records, flag?) => string[])

Type declaration

    • (records, flag?): string[]
    • Inserting Data in Batches

      Parameters

      • records: Record[]

        Recordset

      • Optional flag: Flag

        Transaction flag

      Returns string[]

      ID list of records that are successfully inserted.

      Example


      import * as db from 'db';

      let s = db.object('Student__CST');
      let records = [
      {"name": "Tom","age__CST": "13"},
      {"name": "Jerry","age__CST": "12"},
      ];

      let ids = s.batchInsert(record);
batchUpdate: ((records, flag?) => string[])

Type declaration

    • (records, flag?): string[]
    • Batch Update Records

      Parameters

      • records: Record[]

        Recordset

      • Optional flag: Flag

        Transaction flag

      Returns string[]

      string[] ids of the inserted records

      Example


      import * as db from 'db';

      let s = db.object('Student__CST');

      let records = [
      {"id":"00da000000f2scP5Bw36", "name": "Tom_t"},
      {"id":"00da000000f2scP5Bw37", "name": "Jerry_j"},
      ];

      let ids = s.batchUpdate(record);
compositeInsert: ((records, flag?) => Record[])

Type declaration

    • (records, flag?): Record[]
    • Creating Parent-Child Object Combination Records in Batches

      Parameters

      • records: Record[]

        Parent-child object combination record array

      • Optional flag: Flag

        Transaction flag

      Returns Record[]

      Insert the record set ID list.

      Example


      import * as db from 'db';

      let s = db.object('Customer__CST');

      // Parent and child records need to be associated with each other through associated fields.
      // For example, the following records are associated with each other through `Contacts` to
      // form a combined record.
      let records = [ {
      "name": "hello",
      "count__CST": 123,
      "Contacts": {
      "records": [
      {
      "name": "hello_contact1"
      },
      {
      "name": "hello_contact2"
      }]
      }
      }];

      let ids = s.compositeInsert(records);
      console.log("id list = ", ids);
count: ((condition?) => number)

Type declaration

    • (condition?): number
    • Count the number of records that meet the condition.

      Parameters

      • Optional condition: Condition

        Matching condition

      Returns number

      Number of records that meet the conditions

      Example


      import * as db from 'db';

      let s = db.object('Student__CST');
      let cond = {
      conjunction: db.Conjunction.AND,
      conditions: [
      {
      field: "age__CST",
      "operator": db.Operator.lt,
      "value": 10
      }
      ]
      }
      let num = s.count(cond);
delete: ((id, flag?) => number)

Type declaration

    • (id, flag?): number
    • Deletes records by ID.

      Parameters

      • id: string

        Record ID.

      • Optional flag: Flag

        Operation flag

      Returns number

      Number of records affected

deleteByCondition: ((condition, flag?) => number)

Type declaration

    • (condition, flag?): number
    • Delete records based on conditions.

      Parameters

      • condition: Condition

        Matching condition

      • Optional flag: Flag

        Operation flag

      Returns number

      Number of records affected

      Example


      import * as db from 'db';

      let s = db.object('Student__CST');
      let cond = {
      conjunction: db.Conjunction.AND,
      conditions: [
      {
      field: "name",
      operator: db.Operator.eq,
      value: "Tom"
      }
      ]
      }
      let num = s.deleteByCondition(cond);
insert: ((record, flag?) => string)

Type declaration

    • (record, flag?): string
    • Newly added records

      Parameters

      • record: Record

        Recording

      • Optional flag: Flag

        Operation flag

      Returns string

      Specifies the ID of a new record.

query: ((id, option?, relation?) => Record)

Type declaration

    • (id, option?, relation?): Record
    • Query records by ID.

      Parameters

      • id: string

        Record ID.

      • Optional option: "db".Option

        Query option. In the case of query by ID, you can specify the query field set. Other options have no effect.

      • Optional relation: Relation

        Parent-child relationship. If the parent-child relationship needs to be queried in cascading mode, you need to specify

      Returns Record

      Example


      import * as db from 'db';

      let s = db.object('Student__CST');
      let id = '00da000000f2scP5Bw36';

      let option = {
      options: {
      fields: ["name", "age", "grade"],
      }
      };

      let record = s.query(id, option);
queryByCondition: ((condition, option?, relation?) => Record[])

Type declaration

    • (condition, option?, relation?): Record[]
    • Query records by condition. The number of returned records can be limited. The skip value specifies the number of records from which the query starts, and the limit value specifies the number of returned records.

      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.

      Parameters

      • condition: Condition

        Matching condition

      • Optional option: "db".Option

        Query Options

      • Optional relation: Relation

        Parent-Child Object Relationship

      Returns Record[]

      Recordsets that meet the conditions

      Example


      import * as db from 'db';

      let s = db.object('Student__CST');

      let cond = {
      conjunction: db.Conjunction.AND,
      conditions:[
      {
      field: "age__CST",
      operator: db.Operator.lt,
      "value": 10
      }
      ]
      }

      let records = s.queryByCondition(cond);
update: ((id, record, flag?) => number)

Type declaration

    • (id, record, flag?): number
    • Updates records by ID.

      Parameters

      • id: string

        Record ID.

      • record: Record

        What needs to be updated

      • Optional flag: Flag

        Operation flag

      Returns number

      Number of records affected

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

Type declaration

    • (condition, record, flag?): number
    • Update records based on conditions

      Parameters

      • condition: Condition

        Matching condition

      • record: Record

        What needs to be updated

      • Optional flag: Flag

        Operation flag

      Returns number

      Number of records affected

      Example


      import * as db from 'db';

      let s = db.object('Student__CST');
      let cond = {
      conjunction: db.Conjunction.AND,
      conditions: [
      {
      field: "name",
      operator: db.Operator.eq,
      value: "Tom"
      }
      ]
      }
      let record = {
      "name": "NewTom",
      "age__CST": "14"
      };
      let num = s.updateByCondition(cond, record);