Trying to read last 100 entries from DynamoDB in AWS



I have some entries in a DynamoDB on AWS which contain my IoT Device ID, the time of the entry and a payload with all the data my IoT device measured.

I am wanting to extract this data from the DB to input it into a UI chart.

The only examples I can find on the internet are regarding pushing data to the DB or extracting a single entry.

Can anyone provide any examples or guidance?


Did you find the link below? I haven't use DynamoDB but it appears you can most things that you can do with sql databases. If you want just the samples after a given time you can use that as a query condition, or if you want just the last 100 records then tell it to sort in reverse order and then use limit to fetch only the first 100 (which are actually the last 100). They will be in reverse order but you can re-order after you get them, or perhaps you can get the database driver to sort them again after fetching them.


Thanks for the reply.

Will the node-red-contrib-dynamodb-scan node do the trick?

It is expecting the following input:

    key: "nme",
    reservedKey: "name",
    value: true,
    operator: "="

What do these paramaters represent?


Sorry, no idea. As I said I haven't used DynamoDB. Isn't there a node that allows you to do generic queries on the db?


It would be absolutely beyond me to try and write a node from scratch to access DynamoDB. It appears there are plenty of nodes out there that do it, there's just very little in the way of documentation on how to utilise them.


I wasn't suggesting writing a node that allows generic queries, I was suggesting looking for one that does and then using it.


So how would yo do it without using Node-RED? If you can post your search query here hopefully someone would be able to translate that for you.


OK So I've made some progress after hours of reading. I am able to use the AWS DynamoDB node with scan paramater from node-red-contrib-aws.

I now return content from my DynamoDB with each entry stored into an array. I have written a function to try an extract individual entries from the array and store them into another array to plot on a UI chart.

My code is as follows (to extract time and temperature). But I see nothing in the debug node after the function. Am I doing something wrong?

var x=0;
var myArray = {};
var i=0;

for (i=0; i< msg.payload.ScannedCount; i++) {

myArray[x] = {
time: (msg.payload.Items[i].time),
temperature: (msg.payload.Items[i].payload.M.Temperature)

msg.payload = myArray;
return msg;

You can add debug lines to your function by using node.warn commands see

You can also check the path to the data item using the tool tips as described here:


Had to connect both lines to the function! argh!