Closed shishiranshuman closed 6 years ago
You cannot query on only the range key. Does your global secondary index use your table's range key as its hash key? Showing your model would be helpful.
Sure. Here is the model I am using:
dynogels.define('user-address', {
hashKey : 'user_id',
rangeKey: 'location',
timestamps : true,
schema : {
location: Joi.string(),
pin: Joi.number(),
user_id: Joi.string()
},
indexes: [{
hashKey: 'user_id',
rangeKey: 'location',
name: 'AddressGlobalIndex',
type: 'global',
}],
});
After reading your comment, I think I understand what I am doing wrong. Will let you know
Your index has the same hash key and range key as your table. This is entirely redundant.
Yes, you are right. Fixed it. It was a dumb mistake. Thanx a lot for the help. ✌️
I just started working on DynamoDB so please forgive me if the following seems silly.
hashKey
and arangeKey
. Let's name these as HASH and RANGE respectively.GlobalIndex
is added to the model as well.Now what I want is to get the list of records by
rangeKey
. I don't want to use thescan
operation since it impacts the performance. I am unable to achieve this with thequery
operation. Trying to achieve something like this with dynogels.Any kind of help would be really helpful to me.
Thanks.
Dynogels: 9.0.0 Node: 6.10.3