callback
在define
在VOGELS 2.0除去: https://github.com/ryanfitz/vogels/commit/6d5e70e4fdcfd5f28058298bc63cf749d15837a9
在define
的第二个参数是现在的模式。如果你将一个函数作为第二个参数,你得到这个错误,因为沃格尔认为your're尝试使用VOGELS 1.x中:
if(_.isFunction(config)) {
throw new Error('define no longer accepts schema callback, migrate to new api');
}
来源:https://github.com/ryanfitz/vogels/commit/6d5e70e4fdcfd5f28058298bc63cf749d15837a9#diff-6d186b954a58d5bb740f73d84fe39073R121
所以在检查第二个参数的define
来电。这应该是JSON格式的模式,而不是函数。来自官方文档的示例:
var Account = vogels.define('Account', {
hashKey : 'email',
// add the timestamp attributes (updatedAt, createdAt)
timestamps : true,
schema : {
email : Joi.string().email(),
name : Joi.string(),
age : Joi.number(),
roles : vogels.types.stringSet(),
settings : {
nickname : Joi.string(),
acceptedTerms : Joi.boolean().default(false)
}
}
});