调用create时发生Dynamoose错误

时间:2017-04-28 19:46:54

标签: javascript node.js amazon-web-services amazon-dynamodb

我正在使用节点js和dynamoose与dynamodb进行交互。当我尝试创建一个新对象时,Dynamo会返回此错误。问题不在于请求的内容,而在于动态。正在命中的函数从第5行开始。该错误是由第6行调用函数create()引起的。我检查了模型原型,它确实包含了create函数。

'use strict';
  2
  3   const Aircraft = require('../../aircraft.dynamo/index');
  4
  5   function createAircraft(req, res, next) {
  6     Aircraft.create(req.body, (aircraft) => {
  7       return res.status(201).json(aircraft);
  8     });
  9   }
 10
 11   module.exports = createAircraft;

TypeError: Cannot read property 'name' of undefined
            <br> &nbsp; &nbsp;at NewModel.Model.put (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/dynamoose/lib/Model.js:202:72)
            <br> &nbsp; &nbsp;at Function.Model.create (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/dynamoose/lib/Model.js:247:16)
            <br> &nbsp; &nbsp;at Function.NewModel.create (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/dynamoose/lib/Model.js:99:18)
            <br> &nbsp; &nbsp;at createAircraft (/Users/chrisrijos/SideProjects/aircraft-api/server/api/Aircraft/aircraft.controller/createAircraft/index.js:6:14)
            <br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/express/lib/router/layer.js:95:5)
            <br> &nbsp; &nbsp;at next (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/express/lib/router/route.js:137:13)
            <br> &nbsp; &nbsp;at Route.dispatch (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/express/lib/router/route.js:112:3)
            <br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/express/lib/router/layer.js:95:5)
            <br> &nbsp; &nbsp;at /Users/chrisrijos/SideProjects/aircraft-api/node_modules/express/lib/router/index.js:281:22
            <br> &nbsp; &nbsp;at Function.process_params (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/express/lib/router/inde

0 个答案:

没有答案