0

I use vogels as an object mapper to my DynamoDB, I have a vogels model with the following schema:

Stock: {
   ID: String, (Hash)
   DateUTC: String (Secondary Index) 
 }

if I try to do:

const query = Stock.query('VOD.XLON');

and load all of the items, since I have about 5000 of them:

query.loadAll();
query.exec((err, result) => {});

I get the error:

ValidationException: The provided starting key is invalid.

Is there anything I am doing wrong on my side, or maybe vogels doesn't work well with loading all items that have secondary indices?

inside
  • 3,047
  • 10
  • 49
  • 75

1 Answers1

1

I couldn't replicate the issue. However, the below code works fine for the above model.

var Joi = require('joi');
var vogels = require('vogels');

var AWS = require("aws-sdk");
var creds = new AWS.Credentials('userid', 'password', 'session');

vogels.AWS.config.update({
    region: "us-west-2",
    endpoint: "http://localhost:8000",
    credentials: creds
});

var Stock = vogels.define('Stock', {
    hashKey: 'ID',

    schema: {
        ID: Joi.string(),
        DateUTC: Joi.string()
    },
    indexes: [{
        hashKey: 'DateUTC', name: 'stock_index', type: 'global'
    }],
    tableName: 'stock'
});

const query = Stock.query('1');
query.loadAll();
query.exec((err, result) => {if(!err) {console.log(JSON.stringify(result,undefined, 2))}});
notionquest
  • 37,595
  • 6
  • 111
  • 105