我正在为node.js使用Vogels DynamoDB数据映射器 - 并且在使用DynamoDB(在AWS上)工作时非常困难。对于DynamoDB本地,有 NO 问题 - 它设置架构并在node.js应用程序中完美运行。
但是,在部署到AWS时 - 收到以下错误:
Details:Error: define no longer accepts schema callback, migrate to new api
事情就是我使用的是最新版本的Vogels(https://github.com/ryanfitz/vogels)
那么为什么要迁移到新的api?
答案 0 :(得分:0)
callback
中的{p> define
:
https://github.com/ryanfitz/vogels/commit/6d5e70e4fdcfd5f28058298bc63cf749d15837a9
define
中的第二个参数现在是架构。如果您将函数作为第二个参数传递,则会出现此错误,因为Vogel认为您正在尝试使用Vogels 1.x:
if(_.isFunction(config)) {
throw new Error('define no longer accepts schema callback, migrate to new api');
}
请检查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)
}
}
});