Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql LoopbackJS/AngularJS查找与关系hasOne include separated属性_Mysql_Loopbackjs_Relation_Strongloop_Has One - Fatal编程技术网

Mysql LoopbackJS/AngularJS查找与关系hasOne include separated属性

Mysql LoopbackJS/AngularJS查找与关系hasOne include separated属性,mysql,loopbackjs,relation,strongloop,has-one,Mysql,Loopbackjs,Relation,Strongloop,Has One,我正在mysql数据库中使用loopbackapi在angularjs中进行查找查询 我有一个模型,它与另一个模型有一个hasOne关系 Empresa hasOne Operadora 当我在Empresa中使用include args进行查找时,它会为我带来Operadora属性,但它包含Empresa中的属性,但我希望将其分开 我使用这些示例进行了测试: Empresa.findOne({ include: {"relation" : 'Operadora', 'as': 'Operad

我正在mysql数据库中使用loopbackapi在angularjs中进行查找查询

我有一个模型,它与另一个模型有一个hasOne关系

Empresa hasOne Operadora
当我在Empresa中使用include args进行查找时,它会为我带来Operadora属性,但它包含Empresa中的属性,但我希望将其分开

我使用这些示例进行了测试:

Empresa.findOne({ include: {"relation" : 'Operadora', 'as': 'Operadora'}
Empresa.findOne({ include: {model: 'Operadora', 'as': 'Operadora'} 
Empresa.findOne({ include: {Operadora: 'Operadora'}
Empresa.findOne({ include:  'Operadora'
Empresa.find({ include: {"relation": 'Operadora'}
它带给我这样的感觉:

Empresa.nome
Empresa.nomeOperador
但我想:

Empresa.nome
Empresa.Operadora.nomeOperador
empresa.json

{
  "name": "Empresa",
  "base": "PersistedModel",
  "idInjection": false,
  "options": {
    "validateUpsert": true
  },
  "mysql": {
    "schema": "netexamesapp_prod",
    "table": "Empresa"
  },
  "properties": {
    "id": {
      "type": "Number",
      "id": true,
      "length": null,
      "precision": 10,
      "scale": 0,
      "mysql": {
        "columnName": "id",
        "dataType": "int",
        "dataLength": null,
        "dataPrecision": 10,
        "dataScale": 0,
        "nullable": "N"
      },
      "_selectable": false
    },
    "usuario": {
      "type": "Number",
      "required": true,
      "length": null,
      "precision": 10,
      "scale": 0,
      "mysql": {
        "columnName": "usuario",
        "dataType": "int",
        "dataLength": null,
        "dataPrecision": 10,
        "dataScale": 0,
        "nullable": "N"
      },
      "_selectable": false
    },
    "numcartprof": {
      "type": "String",
      "required": false,
      "length": 255,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "numCartProf",
        "dataType": "varchar",
        "dataLength": 255,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    },
    "numregcons": {
      "type": "String",
      "required": false,
      "length": 255,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "numRegCons",
        "dataType": "varchar",
        "dataLength": 255,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    },
    "tipocontratacao": {
      "type": "String",
      "required": false,
      "length": 255,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "tipoContratacao",
        "dataType": "varchar",
        "dataLength": 255,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    },
    "numcnes": {
      "type": "String",
      "required": false,
      "length": 255,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "numCNES",
        "dataType": "varchar",
        "dataLength": 255,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    },
    "dataexpcro": {
      "type": "Date",
      "required": false,
      "length": null,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "dataExpCRO",
        "dataType": "datetime",
        "dataLength": null,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    },
    "operadora": {
      "type": "Number",
      "length": null,
      "precision": 10,
      "scale": 0,
      "mysql": {
        "columnName": "operadora",
        "dataType": "int",
        "dataLength": null,
        "dataPrecision": 10,
        "dataScale": 0,
        "nullable": "N"
      },
      "_selectable": false
    },
    "datacredenciamento": {
      "type": "Date",
      "required": false,
      "length": null,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "dataCredenciamento",
        "dataType": "datetime",
        "dataLength": null,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    },
    "datadescredenciamento": {
      "type": "Date",
      "required": false,
      "length": null,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "dataDescredenciamento",
        "dataType": "datetime",
        "dataLength": null,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    },
    "created": {
      "type": "Date",
      "required": false,
      "length": null,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "created",
        "dataType": "datetime",
        "dataLength": null,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    },
    "lastupdated": {
      "type": "Date",
      "required": false,
      "length": null,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "lastUpdated",
        "dataType": "datetime",
        "dataLength": null,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    },
    "nomefantasia": {
      "type": "String",
      "required": false,
      "length": 255,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "nomefantasia",
        "dataType": "varchar",
        "dataLength": 255,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    },
    "cnpj": {
      "type": "String",
      "required": false,
      "length": 255,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "cnpj",
        "dataType": "varchar",
        "dataLength": 255,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    },
    "razaosocial": {
      "type": "String",
      "required": false,
      "length": 255,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "razaosocial",
        "dataType": "varchar",
        "dataLength": 255,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    }
  },
  "validations": [],
  "relations": {
        "User": {
         "type": "belongsTo",
         "model": "User",
         "foreignKey": "usuario"
       },
       "Local": {
         "type": "belongsTo",
         "model": "Local",
         "foreignKey": "endereco"
       },
       "Operadora": {
         "type": "hasOne",
         "model": "Operadora",
         "foreignKey": "empresa"
       }
  },
  "acls": [],
  "methods": {}
}
operadora.json

{
  "name": "Operadora",
  "base": "PersistedModel",
  "idInjection": false,
  "options": {
    "validateUpsert": true
  },
  "mysql": {
    "schema": "netexamesapp_prod",
    "table": "Operadora"
  },
  "properties": {
    "id": {
      "type": "Number",
      "id": true,
      "length": null,
      "precision": 10,
      "scale": 0,
      "mysql": {
        "columnName": "id",
        "dataType": "int",
        "dataLength": null,
        "dataPrecision": 10,
        "dataScale": 0,
        "nullable": "N"
      },
      "_selectable": false
    },
    "usuario": {
      "type": "Number",
      "length": null,
      "precision": 10,
      "scale": 0,
      "mysql": {
        "columnName": "usuario",
        "dataType": "int",
        "dataLength": null,
        "dataPrecision": 10,
        "dataScale": 0,
        "nullable": "N"
      },
      "_selectable": false
    },
    "datacredenciamento": {
      "type": "Date",
      "required": false,
      "length": null,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "dataCredenciamento",
        "dataType": "datetime",
        "dataLength": null,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    },
    "datadescredenciamento": {
      "type": "Date",
      "required": false,
      "length": null,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "dataDescredenciamento",
        "dataType": "datetime",
        "dataLength": null,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    },
    "created": {
      "type": "Date",
      "required": false,
      "length": null,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "created",
        "dataType": "datetime",
        "dataLength": null,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    },
    "lastupdated": {
      "type": "Date",
      "required": false,
      "length": null,
      "precision": null,
      "scale": null,
      "mysql": {
        "columnName": "lastUpdated",
        "dataType": "datetime",
        "dataLength": null,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "Y"
      },
      "_selectable": true
    },
    "empresa": {
      "type": "Number",
      "required": false,
      "length": null,
      "precision": 10,
      "scale": 0,
      "mysql": {
        "columnName": "empresa",
        "dataType": "int",
        "dataLength": null,
        "dataPrecision": 10,
        "dataScale": 0,
        "nullable": "Y"
      },
      "_selectable": true
    }
  },
  "validations": [],
  "relations": {
       "User": {
         "type": "belongsTo",
         "model": "User",
         "foreignKey": "usuario"
       },
       "Empresa": {
         "type": "belongsTo",
         "model": "Empresa",
         "foreignKey": "empresa"
       }
     },
  "acls": [],
  "methods": {}
}

有什么想法吗?

你能展示一下你的Empresa模型定义文件吗?Operadora模型文件上传了Operadora.json