Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Issues with auto creating secondary index #193

Open
RaviKAG opened this issue Jul 20, 2020 · 1 comment
Open

Issues with auto creating secondary index #193

RaviKAG opened this issue Jul 20, 2020 · 1 comment

Comments

@RaviKAG
Copy link

RaviKAG commented Jul 20, 2020

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

aws_dataMapper_error

@hxhieu
Copy link

hxhieu commented Nov 11, 2020

@RaviKAG according to this #60 (comment)
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',
      ...
    }
  }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants