Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support local and global secondary indexes on DynamoDB Tables #104

Closed
sam-goodwin opened this issue Feb 3, 2020 · 1 comment · Fixed by #108
Closed

Support local and global secondary indexes on DynamoDB Tables #104

sam-goodwin opened this issue Feb 3, 2020 · 1 comment · Fixed by #108
Assignees
Labels

Comments

@sam-goodwin
Copy link
Owner

sam-goodwin commented Feb 3, 2020

As per #103, we want to support indexes on DynamoDB tables. How should we do this?

I think the desired experience should be similar to how the table is created where the developer only needs to provide a tuple of the columns to index:

@Birowsky's example:

class RestarauntRecord extends Record({
  id: string,
  byUserId: string,
  status: string,
  avgRating: number
    .apply(Minimum(?))
    .apply(Maximum(?))
  starCount: string, // or integer?number? Not sure why your definition defines this column as a string?
}) {}

const table = new DynamoDB.Table(stack, 'id', RestarauntRecord, 'key');
const byStars = table.globalIndex(['starCount', 'avgRating']);
const byUserId = table.globalIndex(['byUserId', 'avgRating']);
const byStatus = table.globalIndex(['status', 'avgRating']);

What about projections? Should developers create another record class to represent the projection, or can we support an array of columns to project?

const projected = table.globalIndex('starCount', 'avgRating',
  // columns to project?
  ['starCount', 'byUserId', 'avgRating']
);
@Birowsky
Copy link

Birowsky commented Feb 5, 2020

Not sure why your definition defines this column as a string?

The type there is explicit: 'One' | 'Two' | 'Three' | 'Four' | 'Five'.

Should developers create another record class to represent the projection, or can we support an array of columns to project?

I see array of columns as the ideal approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants