undefined不是函数 - Sails中的错误

时间:2015-07-02 07:44:07

标签: sails.js waterline

当我运行sails lift时,我在Sails中遇到以下错误,如下所示

usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/util /schema.js:59
attributes[key].type = attributes[key].type.toLowerCase();                                                  
TypeError: undefined is not a function
at        /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/util s/schema.js:59:51
at Array.forEach (native)
at Object.schema.normalizeAttributes  (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/uti ls/schema.js:45:22)
at module.exports (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/core/index.js:42:34)
at module.exports (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/collection/index.js:44:8)
at new child (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/extend.js:17:39)
at initialize (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/collection/loader.js:37:10)
at loadCollection (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline.js:112:29)
at /usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:162:20
at /usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:230:13
at _arrayEach (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:81:9)
at _each (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:72:13)
at Object.async.forEachOf.async.eachOf (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:229:9)
at Object.async.forEach.async.each (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:206:22)
at Array.async.auto.loadCollections (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline.js:125:13)
at /usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:590:38

我的模型具有以下属性

SerialNo: {
  type: 'integer',
  unique: true,
  required: true,
  index: true
},

CreatedAt: {
  type: Date,
  default: Date.now
}

我不明白这个错误。我在相应的控制器中没有任何功能。到目前为止,我还没有定义任何路线。

有人可以帮我解决这个错误吗?

1 个答案:

答案 0 :(得分:0)

在您的模型中,您必须像这样更改模型:

SerialNo: {
  type: 'integer',
  unique: true,
  required: true,
  index: true
},

CreatedAt: {
  type: 'Date',
  default: Date.now
}

注意:在风帆类型中必须有' '