实体操作 (针对增改删查进行讲解)

实体创建(实体业务数据自行添加)

1、书本分类基础档案

操作 描述
名称 书本分类基础档案
编码 baseBookTypes
父实体
引用接口
业务属性 编码 名称 类型 引用
cnt 在管数量 整数
bookTypeName 分类名称 文本
booktypeCode 分类编码 文本

2、书本分类

操作 描述
名称 书分类
编码 bookType
父实体
引用接口
业务属性 编码 名称 类型 引用
cnt 在管数量 整数
bookTypeName 书分类名称 文本
bookTypeCode 书分类编码 文本

3、在馆书籍详细信息

操作 描述
名称 书分类
编码 bookDetail
父实体 书分类
引用接口
业务属性 编码 名称 类型 引用
isexist 是否借阅 单选 是否
bookDate 出版日期 日期
bookAuth 作者 文本
bookName 书名 文本
bookType_id 书分类 单选引用

新增

插入实体

方法 insert("实体url",object,"表单编码")
描述 保存数据到实体,默认自动生成主键
入参  
名称 含义 示例
实体url 实体统一资源标识符(数据建模下实体的URI) GT24744AT196.GT24744AT196.bookType
object 实体对象,支持包含子实体,包含子实体时基于主子表关系 { bookTypeCode: "1001", bookDetailList: [ { bookDate: "2021-11-11", bookAuth: "果果", bookName: "上下五千年", isexist: "1" } ], cnt: 10, bookTypeName: "历史类"};
billNum 表单编码 9e43cb4dList
返回值: 该插入实体对象

代码示例

let AbstractAPIHandler = require('AbstractAPIHandler');
  class MyAPIHandler extends AbstractAPIHandler {
   execute(request) {
      /* 插入实体(主子实体) */
      var object = { bookTypeCode: "1001", bookDetailList: [ { bookDate: "2021-11-11", bookAuth: "果果", bookName: "上下五千年", isexist: "1" } ], cnt: 10, bookTypeName: "历史类"};
      var res = ObjectStore.insert("GT24744AT196.GT24744AT196.bookType",object,"9e43cb4dList");
      return {res};
 }
}
exports({"entryPoint":MyAPIHandler});
// 插入实体(主子实体)res返回的对象
{
    "bookTypeCode": "1001",
    "tenant_id": "wezq3vfl",
    "creator": "cb5cd80d-b57b-447e-a64c-511ece15792b",
    "bookDetailList": [
        {
            "tenant_id": "wezq3vfl",
            "bookDate": "2021-11-11",
            "bookAuth": "果果",
            "bookType_id": "2522274611826944",
            "id": "2522274611843328",
            "pubts": "2021-11-17 19:10:25",
            "bookName": "上下五千年",
            "isexist": "1",
            "yTenantId": "wezq3vfl"
        }
    ],
    "createTime": "2021-11-17 19:10:25",
    "cnt": 10,
    "bookTypeName": "历史类",
    "id": "2522274611826944",
    "pubts": "2021-11-17 19:10:25",
    "yTenantId": "wezq3vfl"
}

批量插入实体(配合yonQL查询实体使用)

方法 insertBatch("实体url",objectList,"表单编码")
描述 批量插入数据到实体,批量保存
入参  
名称 含义 示例
实体url 实体统一资源标识符(数据建模下实体的URI) GT24744AT196.GT24744AT196.bookType
objectList 实体对象列表,支持包含子实体,包含子实体时基于主子表关系 [{ "bookTypeCode": "1003", "cnt": 110, "bookTypeName": "数学类", bookDetailList: [{ bookDate: "2021-11-20", bookAuth: "果果", bookName: "微积分", isexist: "1" } ] }, { "bookTypeCode": "1004", "cnt": 120, "bookTypeName": "计算机类", bookDetailList: [{ bookDate: "2021-11-20", bookAuth: "果果", bookName: "java开发", isexist: "0" } ] } ]
billNum 表单编码 f6f7e02c
返回值: 新增的多个实体对象

代码示例 ①

let AbstractAPIHandler = require('AbstractAPIHandler');
class MyAPIHandler extends AbstractAPIHandler {
    execute(request) {

        /* 批量插入实体 */
        var object = [{
                "bookTypeCode": "1003",
                "cnt": 110,
                "bookTypeName": "数学类",
                bookDetailList: [{
                        bookDate: "2021-11-20",
                        bookAuth: "果果",
                        bookName: "微积分",
                        isexist: "1"
                    }
                ]
            }, {
                "bookTypeCode": "1004",
                "cnt": 120,
                "bookTypeName": "计算机类",
                bookDetailList: [{
                        bookDate: "2021-11-20",
                        bookAuth: "果果",
                        bookName: "java开发",
                        isexist: "0"
                    }
                ]
            }
        ];
        var res = ObjectStore.insertBatch("GT24744AT196.GT24744AT196.bookType", object, "9e43cb4dList");

        return {
            res
        };
    }
}
exports({
    "entryPoint": MyAPIHandler
});
//res返回的对象

[
    {
        "bookTypeCode": "1003",
        "tenant_id": "wezq3vfl",
        "creator": "cb5cd80d-b57b-447e-a64c-511ece15792b",
        "bookDetailList": [
            {
                "tenant_id": "wezq3vfl",
                "bookDate": "2021-11-20",
                "bookAuth": "果果",
                "bookType_id": "2526180346106112",
                "id": "2526180346106113",
                "pubts": "2021-11-20 13:23:32",
                "bookName": "微积分",
                "isexist": "1",
                "yTenantId": "wezq3vfl"
            }
        ],
        "createTime": "2021-11-20 13:23:32",
        "cnt": 110,
        "bookTypeName": "数学类",
        "id": "2526180346106112",
        "pubts": "2021-11-20 13:23:32",
        "yTenantId": "wezq3vfl"
    },
    {
        "bookTypeCode": "1004",
        "tenant_id": "wezq3vfl",
        "creator": "cb5cd80d-b57b-447e-a64c-511ece15792b",
        "bookDetailList": [
            {
                "tenant_id": "wezq3vfl",
                "bookDate": "2021-11-20",
                "bookAuth": "果果",
                "bookType_id": "2526180350300416",
                "id": "2526180350300417",
                "pubts": "2021-11-20 13:23:32",
                "bookName": "java开发",
                "isexist": "0",
                "yTenantId": "wezq3vfl"
            }
        ],
        "createTime": "2021-11-20 13:23:32",
        "cnt": 120,
        "bookTypeName": "计算机类",
        "id": "2526180350300416",
        "pubts": "2021-11-20 13:23:32",
        "yTenantId": "wezq3vfl"
    }
]

代码示例 ② (配合yonQL查询实体)

let AbstractAPIHandler = require('AbstractAPIHandler');
class MyAPIHandler extends AbstractAPIHandler {
    execute(request) {

        var object = ObjectStore.queryByYonQL('select booktypeCode as bookTypeCode, bookTypeName , cnt from GT24744AT196.GT24744AT196.baseBookTypes    ');
        var res = ObjectStore.insertBatch("GT24744AT196.GT24744AT196.bookType", object, "9e43cb4dList");
        return {
            res
        };
    }

}
exports({
    "entryPoint": MyAPIHandler
});
//res返回的对象

[
    {
        "bookTypeCode": "1001",
        "tenant_id": "wezq3vfl",
        "creator": "cb5cd80d-b57b-447e-a64c-511ece15792b",
        "createTime": "2021-11-20 13:35:47",
        "cnt": 10,
        "bookTypeName": "文史类",
        "id": "2526192387608832",
        "pubts": "2021-11-20 13:35:47",
        "yTenantId": "wezq3vfl"
    },
    {
        "bookTypeCode": "1002",
        "tenant_id": "wezq3vfl",
        "creator": "cb5cd80d-b57b-447e-a64c-511ece15792b",
        "createTime": "2021-11-20 13:35:47",
        "cnt": 20,
        "bookTypeName": "数学类",
        "id": "2526192389902592",
        "pubts": "2021-11-20 13:35:47",
        "yTenantId": "wezq3vfl"
    },
    {
        "bookTypeCode": "1003",
        "tenant_id": "wezq3vfl",
        "creator": "cb5cd80d-b57b-447e-a64c-511ece15792b",
        "createTime": "2021-11-20 13:35:47",
        "cnt": 30,
        "bookTypeName": "计算机类",
        "id": "2526192391164160",
        "pubts": "2021-11-20 13:35:47",
        "yTenantId": "wezq3vfl"
    }
]

更新

基于ID更新(更新实体)

方法 updateById("实体url",object,"表单编码")
描述 更新实体,需要包含主键ID。支持更新主实体和子实体。同时更新主实体和子实体时需要包含主实体主键ID, 子实体根据_status状态进行插入、更新或删除。单独更新子实体时,需要包含子实体主键ID
入参  
名称 含义 示例
实体url 实体统一资源标识符(数据建模下实体的URI) GT24744AT196.GT24744AT196.bookType
object 实体对象(更新字段内容),需要包含主键ID。 对子实体的操作通过_status属性标识:支持Insert(新增)、 Update(更新)、Delete(删除) {id: "2526192387608832", cnt: "100", bookDetailList: [{ bookDate: "2021-11-20", bookAuth: "蝈蝈", bookName: "孙中山语录", isexist: "1", hasDefaultInit: true, _status: "Insert" }, { id: "2526195962335488", _status: "Delete" }]}
返回值 更新后的对象

代码示例

let AbstractAPIHandler = require('AbstractAPIHandler');
class MyAPIHandler extends AbstractAPIHandler {
    execute(request) {

        var object = {
            id: "2517829090300160",
            cnt: "100",
            bookDetailList: [{
                    bookDate: "2021-11-14",
                    bookAuth: "蝈蝈",
                    bookName: "孙中山语录",
                    isexist: "1",
                    hasDefaultInit: true,
                    _status: "Insert"
                }, {
                    id: "2517835706765568",
                    _status: "Delete"
                }
            ]
        };
        var res = ObjectStore.updateById("GT24744AT196.GT24744AT196.bookType", object, "9e43cb4dList");
        return {
            res
        };
    }

}
exports({
    "entryPoint": MyAPIHandler
});
//res返回的结果
{
    "bookTypeCode": "1001",
    "tenant_id": "wezq3vfl",
    "modifyTime": "2021-11-20 13:41:20",
    "bookDetailList": [
        {
            "tenant_id": "wezq3vfl",
            "bookDate": "2021-11-20",
            "bookAuth": "蝈蝈",
            "hasDefaultInit": true,
            "bookType_id": "2526192387608832",
            "id": "2526197854916864",
            "bookName": "孙中山语录",
            "isexist": "1",
            "yTenantId": "wezq3vfl"
        },
        {
            "bookType_id": "2526192387608832",
            "id": "2526195962335488",
            "dr": 1
        }
    ],
    "modifier": "cb5cd80d-b57b-447e-a64c-511ece15792b",
    "cnt": 100,
    "bookTypeName": "文史类",
    "id": "2526192387608832",
    "pubts": "2021-11-20 13:41:20"
}

批量更新实体

方法 updateBatch("实体url",objectList,"表单编码")
描述 批量更新实体,支持更新主实体和子实体。同时更新主实体和子实体时需要包 含主实体主键ID,子实体根据_status状态进行插入、更新或删除。单独更新子实体时,需要包含子实体主键ID
入参  
名称 含义 示例
实体url 实体统一资源标识符(数据建模下实体的URI) GT24744AT196.GT24744AT196.bookType
objectList 实体对象(更新字段内容),需要包含主键ID。对子实体的操作通过_status属性标识:支持Insert(新增)、 Update(更新)、Delete(删除) [{id:"2545881679646976",cnt:"2000",bookDetailList: [ { bookDate: "2021-12-05", bookAuth: "果果", bookName: "电学", isexist: "0", hasDefaultInit:true, _status:"Insert"}]},{id:"2526192389902592",cnt:"3000",bookDetailList: [ { bookDate: "2021-12-05", bookAuth: "果子", bookName: "函数", isexist: "1", hasDefaultInit:true, _status:"Insert"}]}]
返回值: 更新后的多个实体

代码示例

 let AbstractAPIHandler = require('AbstractAPIHandler');
 class MyAPIHandler extends AbstractAPIHandler {
     execute(request) {
         /* 批量更新实体 */
       var object = [{id:"2545881679646976",cnt:"2000",bookDetailList: [ { bookDate: "2021-12-05", bookAuth: "果果", bookName: "电学", isexist: "0", hasDefaultInit:true, _status:"Insert"}]},{id:"2526192389902592",cnt:"3000",bookDetailList: [ { bookDate: "2021-12-05", bookAuth: "果子", bookName: "函数", isexist: "1", hasDefaultInit:true, _status:"Insert"}]}];
       var res = ObjectStore.updateBatch("GT24744AT196.GT24744AT196.bookType",object,"9e43cb4dList");
       return {res};
     }
 }
 exports({
     "entryPoint": MyAPIHandler
 });
// res返回的结果
[
    {
        "bookTypeCode": "1007",
        "tenant_id": "wezq3vfl",
        "modifyTime": "2021-12-05 15:53:38",
        "bookDetailList": [
            {
                "tenant_id": "wezq3vfl",
                "bookDate": "2021-12-05",
                "bookAuth": "果果",
                "hasDefaultInit": true,
                "bookType_id": "2545881679646976",
                "id": "2547561563607296",
                "bookName": "电学",
                "isexist": "0",
                "yTenantId": "wezq3vfl"
            }
        ],
        "modifier": "cb5cd80d-b57b-447e-a64c-511ece15792b",
        "cnt": 2000,
        "bookTypeName": "物理类",
        "id": "2545881679646976",
        "pubts": "2021-12-05 15:53:38"
    },
    {
        "bookTypeCode": "1002",
        "tenant_id": "wezq3vfl",
        "modifyTime": "2021-12-05 15:53:38",
        "bookDetailList": [
            {
                "tenant_id": "wezq3vfl",
                "bookDate": "2021-12-05",
                "bookAuth": "果子",
                "hasDefaultInit": true,
                "bookType_id": "2526192389902592",
                "id": "2547561566523648",
                "bookName": "函数",
                "isexist": "1",
                "yTenantId": "wezq3vfl"
            }
        ],
        "modifier": "cb5cd80d-b57b-447e-a64c-511ece15792b",
        "cnt": 3000,
        "bookTypeName": "数学类",
        "id": "2526192389902592",
        "pubts": "2021-12-05 15:53:38"
    }
]

根据wrapper条件更新实体

方法 update(URI,toUpdate,updateWrapper,"表单编码")
描述 根据wrapper条件更新实体数据,支持更新主实体和子实体。同时更新主实体和子实体时需要包 含主实体主键ID,子实体根据_status状态进行插入、更新或删除。单独更新子实体时,需要包含子实体主键ID
入参  
名称 含义 示例
实体url 实体统一资源标识符(数据建模下实体的URI) GT24744AT196.GT24744AT196.bookType
toUpdate 根据wrapper条件更新实体数据。对子实体的操作通过_status属性标识:支持Insert(新增)、 Update(更新)、Delete(删除) var updateWrapper = new Wrapper(); updateWrapper.eq("bookTypeName","计算机类").ge("cnt","200");
updateWrapper 更新的条件
返回值 更新后的实体

代码示例

  let AbstractAPIHandler = require('AbstractAPIHandler');
  class MyAPIHandler extends AbstractAPIHandler {
      execute(request) {
        /* 根据wrapper条件更新实体 */
        // 更新条件
        var updateWrapper = new Wrapper();
        // 书本分类名为计算机类、件数>200
        updateWrapper.eq("bookTypeName","计算机类").ge("cnt","200");
        // 待更新字段内容
        var toUpdate = {bookTypeName:"计算机类别",bookDetailList:[ { bookDate: "2021-12-05", bookAuth: "蝈蝈", bookName: "C++", isexist: "1", hasDefaultInit:true, _status:"Insert"}]};
        var res = ObjectStore.update("GT24744AT196.GT24744AT196.bookType",toUpdate,updateWrapper,"9e43cb4dList"); 
        return {res};
      }
  }
  exports({
      "entryPoint": MyAPIHandler
  });
// res返回的结果
[
    {
        "bookTypeCode": "1003",
        "tenant_id": "wezq3vfl",
        "modifyTime": "2021-12-05 16:13:48",
        "bookDetailList": [
            {
                "tenant_id": "wezq3vfl",
                "bookDate": "2021-12-05",
                "bookAuth": "蝈蝈",
                "hasDefaultInit": true,
                "bookType_id": "2526192391164160",
                "id": "2547581387510016",
                "bookName": "C++",
                "isexist": "1",
                "yTenantId": "wezq3vfl"
            }
        ],
        "modifier": "cb5cd80d-b57b-447e-a64c-511ece15792b",
        "cnt": 300,
        "bookTypeName": "计算机类别",
        "id": "2526192391164160",
        "pubts": "2021-12-05 16:13:48"
    }
]

删除

删除实体

方法 deleteById("实体url",object,"表单编码")
描述 逻辑删除实体,需要包含主键ID。支持删除主实体和子实体。如果删除的是主实体,则级联删除子实体
入参  
名称 含义 示例
实体url 实体统一资源标识符(数据建模下实体的URI) GT24744AT196.GT24744AT196.bookType
object 主实体需要主键ID、pubts。子实体不校验时间戳,仅需要ID {id:"2526192387608832",pubts:"2021-12-02 19:07:35"}
返回值 删除实体的对象(id+时间戳基本信息)

代码示例

let AbstractAPIHandler = require('AbstractAPIHandler');
class MyAPIHandler extends AbstractAPIHandler {
    execute(request) {
      // 注意事件戳(必须和数据库的一致、否则提示网络上有其他人操作或者已经关闭等错误提示)
      var object = {id:"2526192387608832",pubts:"2021-12-02 19:07:35"};
      var res = ObjectStore.deleteById("GT24744AT196.GT24744AT196.bookType",object,"9e43cb4dList");
      return {res};
    }
}
exports({
    "entryPoint": MyAPIHandler
});
//res 返回的结果
{
    "_keyName": "id",
    "_entityName": "GT24744AT196.GT24744AT196.bookType",
    "id": "2526192387608832",
    "pubts": "2021-12-02 19:07:35",
    "_status": "Update"
}

条件删除实体

方法 deleteByMap("实体url",object,"表单编码")
描述 基于Map条件逻辑删除实体。支持删除主实体和子实体。如果删除的是主实体,则级联删除子实体
入参  
名称 含义 示例
实体url 实体统一资源标识符(数据建模下实体的URI) GT24744AT196.GT24744AT196.bookType
object 条件值,及关联的子实体。association字段及association关联的子实体可选,如果不填则只删除主实体。否则查询主实体及相关的子实体 {name:"qqq",creator:"xxx",association:["pX000008_tabpane0List"]}
返回值 删除的实体对象(id+时间戳基本信息)

代码示例

  let AbstractAPIHandler = require('AbstractAPIHandler');
  class MyAPIHandler extends AbstractAPIHandler {
      execute(request) {
         /* 条件删除实体*/
        var object = {bookTypeName:"数学类"};
        var res = ObjectStore.deleteByMap("GT24744AT196.GT24744AT196.bookType",object,"9e43cb4dList");
        return {res};
      }
  }
  exports({
      "entryPoint": MyAPIHandler
  });
// res返回的结果
[
    {
        "_keyName": "id",
        "bookTypeName": "数学类",
        "_entityName": "GT24744AT196.GT24744AT196.bookType",
        "id": "2526192389902592",
        "_status": "Update",
        "pubts": "2021-12-05 15:53:38"
    }
]

批量删除实体

方法 deleteBatch("实体url",objectList,"表单编码")
描述 基于多个ID逻辑删除实体。如果删除的是主实体,则级联删除子实体
入参  
名称 含义 示例
实体url 实体统一资源标识符(数据建模下实体的URI) GT24744AT196.GT24744AT196.bookType
objectList id列表 [{id:"1227ee93a5564f2e8c3b228e67b076c7",pubts:"2020-03-14 16:08:48",pX000008_tabpane0List:[{id:"290985a577154708a62dcea4621b03ca",_status:"Delete"}]},{id:"39dccc83fca0468d98ffc485d8d09d11",pubts:"2020-03-14 16:43:16",pX000008_tabpane0List:[{id:"99143865e4b24689bee0d6adf77f0426",_status:"Delete"},{id:"9924fa3fa63c47c1b56d69edb983a90f",_status:"Delete"}]}]
返回值 删除的多个实体对象

代码示例

   let AbstractAPIHandler = require('AbstractAPIHandler');
   class MyAPIHandler extends AbstractAPIHandler {
       execute(request) {
         /* 批量删除实体(注意主实体时间戳必须和数据库一致、否则提示错误信息、子实体可不写时间戳) */
         var object = [{id:"2545881679646976",pubts:"2021-12-05 15:53:38",bookDetailList:[{id:"2547561563607296"}]},{id:"2526192391164160",pubts:"2021-12-05 16:13:48"}];
         var res = ObjectStore.deleteBatch("GT24744AT196.GT24744AT196.bookType",object,"9e43cb4dList");
         return {res};
       }
   }
   exports({
       "entryPoint": MyAPIHandler
   });
// res返回的结果
[
    {
        "bookDetailList": [
            {
                "_parent": {
                    "$ref": "$[0]"
                },
                "_keyName": "id",
                "_entityName": "GT24744AT196.GT24744AT196.bookDetail",
                "id": "2547561563607296",
                "_status": "Delete"
            }
        ],
        "_keyName": "id",
        "_entityName": "GT24744AT196.GT24744AT196.bookType",
        "id": "2545881679646976",
        "pubts": "2021-12-05 15:53:38",
        "_status": "Update"
    },
    {
        "_keyName": "id",
        "_entityName": "GT24744AT196.GT24744AT196.bookType",
        "id": "2526192391164160",
        "pubts": "2021-12-05 16:13:48",
        "_status": "Update"
    }
]

查询

查询实体

方法 selectById("实体url",object)
描述 基于id查询实体。如果查询的是主实体,则级联查询子实体
入参  
名称 含义 示例
实体url 实体统一资源标识符(数据建模下实体的URI) GT24744AT196.GT24744AT196.bookType
object 实体对象主键ID,及关联的子实体。compositions字段可选,如果不填则只查询主实体。否则查询主实体及相关的子实体。compostions中的name字段是关联的子实体。支持多级查询 { id:"2547627643785472", // 查子实体 compositions:[ { name:"bookDetailList", // 查孙实体(没有则不写) compositions:[ ] } ] }
返回值 查询的实体对象

查询实体代码示例

    let AbstractAPIHandler = require('AbstractAPIHandler');
    class MyAPIHandler extends AbstractAPIHandler {
        execute(request) {
          // 查主实体
          var object = {
            id:"2547627643785472",
            // 查子实体(没有则不写)
            compositions:[
              {
                name:"bookDetailList",
                // 查孙实体(没有则不写)
                compositions:[

                ]
              }
            ]
          };
          //实体查询
          var res = ObjectStore.selectById("GT24744AT196.GT24744AT196.bookType",object);
          return {res};
        }
    }
    exports({
        "entryPoint": MyAPIHandler
    });
// res返回结果
{
    "bookTypeCode": "1001",
    "tenant_id": "wezq3vfl",
    "creator": "cb5cd80d-b57b-447e-a64c-511ece15792b",
    "createTime": "2021-12-05 17:00:51",
    "bookDetailList": [
        {
            "tenant_id": "wezq3vfl",
            "bookDate": "2021-12-05",
            "bookAuth": "楠楠",
            "bookType_id": "2547627643785472",
            "id": "2547627643785473",
            "pubts": "2021-12-05 17:00:51",
            "bookName": "张爱玲随笔",
            "isexist": "2",
            "dr": 0
        }
    ],
    "cnt": 20,
    "bookTypeName": "文史类",
    "id": "2547627643785472",
    "pubts": "2021-12-05 17:00:51",
    "dr": 0
}

YonQL实体查询

方法 queryByYonQL(sql)
描述  
入参  
名称 含义 示例
sql YonQL select * from online0205.treeucfbase.treeucfbase_Treetable where parent like 'root%'
返回值 查询的实体对象

代码示例

ObjectStore.queryByYonQL('select * from online0205.treeucfbase.treeucfbase_Treetable')

批量查询实体

方法 selectBatchIds("实体url", object)
描述  
入参  
名称 含义 示例
idList 实体对象主键ID,及关联的子实体。association字段可选,如果不填则只查询主实体。否则查询主实体及相关的子实体  
返回值 查询的多个实体对象

实体查询代码示例

    let AbstractAPIHandler = require('AbstractAPIHandler');
    class MyAPIHandler extends AbstractAPIHandler {
        execute(request) {

            /* 批量查询实体 */
            //查询内容
            var object = {
                ids: ["2547627643785472", "2547647992566016"],
                // 子实体(不查则不写)
                compositions: [{
                        name: "bookDetailList",
                        // (孙实体)不查则不写
                        compositions: [
                            //查询条件
                        ]
                    }
                ]
            };
            //实体查询
            var res = ObjectStore.selectBatchIds("GT24744AT196.GT24744AT196.bookType", object);
            return{res};

        }
    }
    exports({
        "entryPoint": MyAPIHandler
    });
// res返回的结果
[{
        "bookTypeCode": "1001",
        "tenant_id": "wezq3vfl",
        "creator": "cb5cd80d-b57b-447e-a64c-511ece15792b",
        "createTime": "2021-12-05 17:00:51",
        "bookDetailList": [{
                "tenant_id": "wezq3vfl",
                "bookDate": "2021-12-05",
                "bookAuth": "楠楠",
                "bookType_id": "2547627643785472",
                "id": "2547627643785473",
                "pubts": "2021-12-05 17:00:51",
                "bookName": "张爱玲随笔",
                "isexist": "2",
                "dr": 0
            }
        ],
        "cnt": 20,
        "bookTypeName": "文史类",
        "id": "2547627643785472",
        "pubts": "2021-12-05 17:00:51",
        "dr": 0
    }, {
        "bookTypeCode": "1002",
        "tenant_id": "wezq3vfl",
        "creator": "cb5cd80d-b57b-447e-a64c-511ece15792b",
        "createTime": "2021-12-05 17:21:33",
        "bookDetailList": [{
                "tenant_id": "wezq3vfl",
                "bookDate": "2021-12-05",
                "bookAuth": "楠楠",
                "bookType_id": "2547647992566016",
                "id": "2547647992566017",
                "pubts": "2021-12-05 17:21:33",
                "bookName": "java开发",
                "isexist": "2",
                "dr": 0
            }
        ],
        "cnt": 30,
        "bookTypeName": "计算机类",
        "id": "2547647992566016",
        "pubts": "2021-12-05 17:21:33",
        "dr": 0
    }
]

条件查询实体

方法 selectByMap(实体url,columnMap)
描述  
入参  
名称 含义 示例
columnMap 条件值 {cnt:"20"}
返回值 查询的实体对象

查询实体代码示例

let AbstractAPIHandler = require('AbstractAPIHandler');
class MyAPIHandler extends AbstractAPIHandler {
    execute(request) {

       /*条件查询实体 */
       // 找数量为20的数据
      var object = {cnt:"20"};
      var res = ObjectStore.selectByMap("GT24744AT196.GT24744AT196.bookType",object);
        return{res};

    }
}
exports({
    "entryPoint": MyAPIHandler
});
// res 的返回结果
[
    {
        "bookTypeCode": "1001",
        "tenant_id": "wezq3vfl",
        "creator": "cb5cd80d-b57b-447e-a64c-511ece15792b",
        "createTime": "2021-12-05 17:00:51",
        "cnt": 20,
        "bookTypeName": "文史类",
        "id": "2547627643785472",
        "pubts": "2021-12-05 17:00:51",
        "dr": 0
    }
]
Copyright © 用友 -【生态技术部】 2021 all right reserved,powered by Gitbook修订时间: 2021-12-07 19:02:02

results matching ""

    No results matching ""