通过REST API

时间:2015-07-31 00:30:05

标签: node.js strongloop loopback

我有两个这样的环回模型:

{
  "name": "se_unvrs_fields_cat",
  "base": "PersistedModel",
  "options": {
    "validateUpsert": true
  },
  "mysql": {
    "schema": "segtool",
    "table": "se_unvrs_fields_cat"
  },
  "properties": {
    "cat_id": {
      "type": "Number",
      "id": true,
      "required": true
    },
    "cat_nm": {
      "type": "string",
      "required": false
    },
    "insrt_dt": {
      "type": "Date",
      "required": false
    },
    "insrt_user_id": {
      "type": "String",
      "required": false
    },
    "upd_dt": {
      "type": "Date",
      "required": false
    },
    "upd_user_id": {
      "type": "String",
      "required": false
    }
  },
  "validations": [],
  "relations": {
    "seUnvrsFields": {
      "type": "hasMany",
      "model": "se_unvrs_fields",
      "foreignKey": "cat_id"
    }
  },
  "acls": [],
  "methods": []
}

和另一个:

{
  "name": "se_unvrs_fields",
  "base": "PersistedModel",
  "options": {
    "validateUpsert": true
  },
  "mysql": {
    "schema": "segtool",
    "table": "se_unvrs_fields"
  },
  "properties": {
    "unvrs_field_nm": {
      "type": "String",
      "required": false,
      "id": true
    },
    "cat_id": {
      "type": "Number",
      "required": true,
      "index": true
    },
    "insrt_dt": {
      "type": "Date",
      "required": false
    },
    "insrt_user_id": {
      "type": "String",
      "required": false
    },
    "upd_dt": {
      "type": "Date",
      "required": false
    },
    "upd_user_id": {
      "type": "String",
      "required": false
    }
  },
  "validations": [],
  "relations": {
    "seUnvrsFieldsCat": {
      "type": "belongsTo",
      "model": "se_unvrs_fields_cat",
      "foreignKey": "cat_id"
    }
  },
  "acls": [],
  "methods": []
}

当我在REST api中查询seSegnUnvrsFields模型时:

{"include": "seUnvrsFieldsCat"}

我在CMD中收到此错误:

c:\BMO\segtool\node_modules\loopback-connector-mysql\node_modules\mysql\lib\protocol\Parser.js:82
    throw err;
          ^
Error: Invalid date: Invalid Date
    at DateType (c:\BMO\segtool\node_modules\loopback-datasource-juggler\lib\model-builder.js:521:11)
    at ModelConstructor.Object.defineProperty.set [as insrt_dt] (c:\BMO\segtool\node_modules\loopback-datasource-juggler\lib\model-builder.js:456:81)
    at ModelConstructor.ModelBaseClass._initProperties (c:\BMO\segtool\node_modules\loopback-datasource-juggler\lib\model.js:177:17)
    at ModelConstructor.ModelBaseClass (c:\BMO\segtool\node_modules\loopback-datasource-juggler\lib\model.js:46:8)
    at ModelConstructor (c:\BMO\segtool\node_modules\loopback-datasource-juggler\lib\model-builder.js:177:22)
    at ModelConstructor (c:\BMO\segtool\node_modules\loopback-datasource-juggler\lib\model-builder.js:177:22)
    at new ModelConstructor (c:\BMO\segtool\node_modules\loopback-datasource-juggler\lib\model-builder.js:177:22)
    at c:\BMO\segtool\node_modules\loopback-datasource-juggler\lib\include.js:172:48
    at c:\BMO\segtool\node_modules\loopback-datasource-juggler\node_modules\async\lib\async.js:125:13
    at Array.forEach (native)

它说它是一个日期时间错误,但我在其他模型中使用相同的日期时间,它工作正常。什么是奇怪的是,如果我查询

{"include": "seUnvrsFields"}
来自seUnvrsFieldsCat,这是有效的,但不是其他方式......

0 个答案:

没有答案