I am using Vogels, DynamoDB data mapper for NodeJS. I am querying against a global index according to the Vogels' documentation. All I have done is, created a model with a global secondary index like this:
let MyModel = vogels.define('MyModel', {
hashKey: 'uuid',
timestamps: true,
updatedAt: 'updated_at',
createdAt: 'created_at',
schema: MyModelBaseSchema,
indexes : [{
hashKey : 'gameTitle', rangeKey : 'topScore', name : 'GameTitleIndex', type : 'global'
}]
});
and querying against this index
MyModel.query('game 1')
.usingIndex('GameTitleIndex')
.loadAll()
.select("COUNT");
When running any tests it shows an exception ValidationException: The table does not have the specified index: GameTitleIndex
According to the documentation, this is all I have to do to get data. Is there anything which I have missed to query this index? Any answers will be appreciated. Thanks in advance.
In case someone's stuck at the same issue, here is the answer: After creating a new index in model, either local secondary index or global secondary index, Migrations are to be run. Only after then the table will have the specified index. Refer to this issue for more clarification.