30) { const time = moment().subtract(days, 'days'); const unix_created_at = time.valueOf().toString(); const params = { TableName, ConsistentRead: true, KeyConditionExpression: 'id = :v1 AND unix_created_at > :v2', Limit: days * 24, ScanIndexForward: false, ExpressionAttributeValues: { ':v1': { S: id }, ':v2': { N: unix_created_at }, }, }; return new Promise(function(resolve, reject) { dynamodb.query(params, function(err, data) { if (err) { reject(err, err.stack); // an error occurred } else { if (data.Items.length > 0) { const result = aggItems(data.Items); resolve(result); } else { resolve(null); } } }); }); }