在带有炸药的 Vogels 上,找不到请求的资源

On Vogels with dynalite, Requested resource not found

有人可以分享有关如何 vogels working 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: 'foo@example.com',
}, 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

任何提示将不胜感激:)

问题已解决。

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

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

所以我尝试用函数 vogels vogels.createTables 创建 table。之后,调用 myVogelsModel.create 函数就可以正常工作了。

FI: The topic on github.