Closed cdhowie closed 8 years ago
You can use dynogels as stated to query keys that are in a list:
Account.getItems(['foo@example.com','bar@example.com', 'test@example.com'], function (err, accounts) {
console.log('loaded ' + accounts.length + ' accounts'); // prints loaded 3 accounts
});
https://github.com/clarkie/dynogels#batch-get-items
@cdhowie can you point me to the docs that show the list of key conditions supported by dynamoDB as I'm not convinced they do. Their own gui only supports the ones supported by dynogels and even then it's only on range keys:
Sorry, I left out a key detail here: I'm trying to do exactly what you show in your example code (I know about this feature and use it elsewhere) but in this case I'm trying to do this with a GSI. I can see how I'd do that using the document client API, but I can't find a way to do it with dynogels.
Could you post a link to the docs? Thanks
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#query-property
Note KeyConditions..ComparisonOperator.
So to clarify, what I want to do is query with an IN condition against the hash key of a GSI.
Great, thanks. Could you post the code you've got using the aws-sdk? Thanks
So this seems to be a case where the documentation for DocumentClient is incorrect. Unfortunately, DynamoDB doesn't even support batch get operations on GSIs. The only apparent way to get all records in a GSI where the hash key is in a set of values is to execute a query operation per value. :(
Ah ok, thanks for taking the time to let me know.
Here we can see the list of supported key conditions in dynogels. There are more conditions supported by DynamoDB itself:
'EQ | NE | IN | LE | LT | GE | GT | BETWEEN | NOT_NULL | NULL | CONTAINS | NOT_CONTAINS | BEGINS_WITH'
. In this particular case, I need theIN
operator.However, this may be more troublesome as I'm not sure if the
query()
function will work without an argument. In my case, I have a set of values and I want to get all records where the hash key is equal to one of those values. It doesn't appear that dynogels supports this, which means I would have to usescan()
instead.