Getting only one item or the first item of the table in Dynamo DB
Scan the table or index setting the Limit
parameter to 1. If there is no filter expression this will return the first item.
Query the table and get only the first result and only 1 object.
const params = {
TableName: "Logins",
Limit : 1
},
docClient = new AWS.DynamoDB.DocumentClient(),
returnObj = {};
docClient.scan(params, function(err, data){
if(err) {
console.log(err)
} else {
console.log(data)
}