DynamoDB client for NodeJS and browser with a fluent api to build requests. We take care of the type mapping between JS and DynamoDB, customizable trough typescript decorators.
It would be good to show examples of querying on a GSI in the documentation. I was scratching my head for a while because I had code like this:
async function find(pk: string, skPrefix?: string, index?: MyIndexEnum): Promise<Foo[]> {
let query = store.query().wherePartitionKey(pk);
if (index) {
query = query.index(index);
}
if (skPrefix && !isEmpty(skPrefix)) {
query = query.whereSortKey().beginsWith(skPrefix.toLowerCase());
}
console.debug(`Query ${index || 'table'} for "${pk}" begins_with(${skPrefix})`);
return query.exec();
}
I didn't realize that you had to call .index(...)before calling wherePartitionKey. That seems a bit counterintuitive on this builder pattern, but if it was documented along with the query documentation, that'd make it easy to see.
It would be good to show examples of querying on a GSI in the documentation. I was scratching my head for a while because I had code like this:
I didn't realize that you had to call
.index(...)
before callingwherePartitionKey
. That seems a bit counterintuitive on this builder pattern, but if it was documented along with the query documentation, that'd make it easy to see.