zoukankan      html  css  js  c++  java
  • 联合查询的另一种实现方式—利用数组

    let itemKey = 0;
    for (const addressItem of addressList) {
    addressList[itemKey].province_name = await this.model('region').getRegionName(addressItem.province_id);
    addressList[itemKey].city_name = await this.model('region').getRegionName(addressItem.city_id);
    addressList[itemKey].district_name = await this.model('region').getRegionName(addressItem.district_id);
    addressList[itemKey].full_region = addressList[itemKey].province_name + addressList[itemKey].city_name + addressList[itemKey].district_name;
    itemKey += 1;
    }

    return this.success(addressList);


    针对数组,这里采用的办法是可以取代联合查询的。这里涉及了两个表address以及region,对于model层的region进行操作。其中:
    getRegionName(regionId) {
    var _this3 = this;

    return _asyncToGenerator(function* () {
    return _this3.where({ id: regionId }).getField('name', true);
    })();
    }
    说白了,通过对数组进行改装,从而实现,联合的查询
    
    
  • 相关阅读:
    [Tool]使用ConfuserEx混淆代码
    Python_安装官方whl包和tar.gz包
    0017_集合的补充
    0016_练习题d2
    0015_各数据类型方法代码实现
    0014_基本数据类型及常用方法剖析
    0013_运算符
    0012_编码转换
    0011_练习题d1
    0010_while循环
  • 原文地址:https://www.cnblogs.com/superAnny/p/8422034.html
Copyright © 2011-2022 走看看