Skip to content

Instantly share code, notes, and snippets.

@RyPope
Created February 5, 2019 04:59
Show Gist options
  • Save RyPope/14890d4d8645d7e6569e4e94ca2221d8 to your computer and use it in GitHub Desktop.
Save RyPope/14890d4d8645d7e6569e4e94ca2221d8 to your computer and use it in GitHub Desktop.
@Module
public class FeedTableModule {
@Provides
@Singleton
@Named(value=TableConstants.FEED_TABLE_NAME)
Table feedTable(final DynamoDB dynamoDB) {
return dynamoDB.getTable(TableConstants.FEED_TABLE_NAME);
}
@Provides
@Singleton
@Named(value=TableConstants.FEED_USERID_CREATED_AT_INDEX)
Index feedSortedIndex(final @Named(value=TableConstants.FEED_TABLE_NAME) Table feedTable) {
return feedTable.getIndex(TableConstants.FEED_USERID_CREATED_AT_INDEX);
}
@Provides
@Singleton
@Named(value=QueryConstants.FEED_SORTED_QUERY)
QuerySpec feedSortedQuery() {
return new QuerySpec()
.withKeyConditionExpression("#U = :userId")
.withNameMap(new NameMap()
.with("#U", TableConstants.FEED_USERID_COLUMN))
.withScanIndexForward(false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment