I'm trying to get the latest rows of a table, using Dynamoose.
I read about query().ascending()
and query.descending()
, but I need to query the whole table, which requires the hashkey to be empty, as far as I understood. scan()
doesn't support sorting.
Something like:
MyModel
.scan() // 1. scan the whole table
.descending('my_date') // 2. sort by descending by a date
.limit(100) // 3. limit the results to 100
.exec(function(error, data) {
// return error or data
});
Does anyone know how to get the latest rows?
Thanks in advance!