有人可以分享有关如何使vogels工作dynalite的信息吗?

以下是在计算机上本地实例化数据库服务器的操作:

import dynalite from 'dynalite';
import packageJSON from '../package.json'

// Returns a standard Node.js HTTP server
const dynaliteServer = dynalite({ path: '../mydb', createTableMs: 50 })

dynaliteServer.listen(packageJSON.config.endpointPort, function (err) {
    if (err) throw err
    console.log('Dynalite started on port ' + packageJSON.config.endpointPort);
});


这是我尝试初始化vogels的方法:

import packageJSON from '../package.json';
import AWS from 'aws-sdk';
import vogels from 'vogels';

export default function initContext() {
  const AWSConfig = {
    accessKeyId: packageJSON.config.KEY,
    secretAccessKey: packageJSON.config.SECRET,
    region: packageJSON.config.region,
    endpoint: packageJSON.config.endpoint
  };

  //config AWD
  AWS.config.update(AWSConfig);

  //create dynamodb instance
  const dynamodb = new AWS.DynamoDB(AWSConfig);

  //config vogels AWS
  vogels.AWS.config.update(AWSConfig);
  vogels.dynamoDriver(dynamodb);

  return {
    dynamodb,
    vogels
  };
}


我已经定义了一个模型,并尝试在名为initDB.js的文件中创建它:

initContext();

myVogelsModel.create({
    name: 'foo',
    email: '[email protected]',
}, function (err, model) {
    console.log(err);
});


但这只返回了错误:

{ [ResourceNotFoundException: Requested resource not found]
  message: 'Requested resource not found',
  code: 'ResourceNotFoundException',
  time: Thu Feb 09 2017 22:53:46 GMT+0100 (Paris, Madrid),
  requestId: 'CATZQFWSMVJKOLP0YTIMU9IEVSLJBVAB7NJB8L3EIHXCDXLT30AQ',
  statusCode: 400,
  retryable: false,
  retryDelay: 0 }
C:\Users\damien\Documents\workspace\myProject\node_modules\aws-sdk\lib\request.js:31
            throw err;
            ^

TypeError: Cannot read property 'get' of undefined
    at C:/Users/damien/Documents/workspace/myProject/src/initDB.js:23:34
    at C:\Users\damien\Documents\workspace\myProject\node_modules\vogels\lib\table.js:193:16
    at Response.<anonymous> (C:\Users\damien\Documents\workspace\myProject\node_modules\vogels\lib\table.js:69:14)
    at Request.<anonymous> (C:\Users\damien\Documents\workspace\myProject\node_modules\aws-sdk\lib\request.js:355:18)
    at Request.callListeners (C:\Users\damien\Documents\workspace\myProject\node_modules\aws-sdk\lib\sequential_executor.js:105:20)
    at Request.emit (C:\Users\damien\Documents\workspace\myProject\node_modules\aws-sdk\lib\sequential_executor.js:77:10)
    at Request.emit (C:\Users\damien\Documents\workspace\myProject\node_modules\aws-sdk\lib\request.js:668:14)
    at Request.transition (C:\Users\damien\Documents\workspace\myProject\node_modules\aws-sdk\lib\request.js:22:10)
    at AcceptorStateMachine.runTo (C:\Users\damien\Documents\workspace\myProject\node_modules\aws-sdk\lib\state_machine.js:14:12)
    at C:\Users\damien\Documents\workspace\myProject\node_modules\aws-sdk\lib\state_machine.js:26:10


任何提示将不胜感激:)

最佳答案

该问题已解决。

问题似乎是我用定义为Number的键创建了表(使用aws-sdk-js dynamodb.createTable函数),而我的Vogels模型的键是UUID(又名string)。

尝试使用vogels在表中添加项目时:无效:这令人困惑,因为使用命令aws dynamodb list-tables --endpoint-url http://localhost:4567:我得到了正确的表列表。

因此,我尝试使用功能vogels vogels.createTables创建表。之后,调用myVogelsModel.create函数可以很好地工作。

FI:The topic on github

10-06 03:18