我正在为node.js使用Vogels DynamoDB数据映射器--在DynamoDB (在AWS上)中工作一直很困难。对于DynamoDB本地程序,没有问题--它设置模式并在node.js应用程序中完美地工作。
但是,当部署到AWS时-得到以下错误:
Details:Error: define no longer accepts schema callback, migrate to new api问题是我使用的是Vogels的最新版本(https://github.com/ryanfitz/vogels)
那么,为什么要迁移到新的api呢?
发布于 2016-12-24 10:35:24
callback in define在Vogels 2.0: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)
}
}
});https://stackoverflow.com/questions/41312036
复制相似问题