Open RaviKAG opened 4 years ago
@RaviKAG according to this https://github.com/awslabs/dynamodb-data-mapper-js/issues/60#issuecomment-396792816
Your ensureTableExists
must have the indexOptions
block to define each of your indexes
this.dynamoDB.mapper.ensureTableExists(Comment, {
readCapacityUnits: 5,
writeCapacityUnits: 5,
indexOptions: {
commentRefId: {
type: 'global',
...
}
}
}
I am having issues with creating secondary index. This is how my Entity class looks like
import { attribute, rangeKey, table, hashKey} from '@aws/dynamodb-data-mapper-annotations'; @table('Comments') export class Comment{ @hashKey({indexKeyConfigurations: { commentRefId: 'HASH' } }) commentRefId: string;
@rangeKey({ defaultProvider: () => new Date() }) createdOn: Date;
@attribute() data?: string;
@attribute() author: string;
@attribute() authorId: number;
@attribute() uuid: string; }
create table code this.dynamoDB.mapper.ensureTableExists(Comment, { readCapacityUnits: 5, writeCapacityUnits: 5}
When I run this code, it returns error saying (node:33860) UnhandledPromiseRejectionWarning: Error: No options provided for commentRefId index