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)
}
}
});