let AWS = require('aws-sdk');
let util = require('util');
AWS.config.update({
region: 'us-east-1'
});
let connection = new AWS.DynamoDB.DocumentClient();
let params = {
TableName: 'user_details',
KeyConditionExpression: 'user_id = :user_id and user_relation begins_with :user_relation',
ExpressionAttributeValues: {
':user_id': "1234",
':user_relation': "followed-by"
}
};
console.log('getQuery Params => ', params);
let dynamoDb = util.promisify(connection.query).bind(connection);
let results = await dynamoDb(params);
console.log('results => ', results);
const params = {
TableName: 'user_details',
KeyConditionExpression: '#user_id = :user_id and begins_with(#user_relation, :user_relation)',
ExpressionAttributeNames:{
"#user_id": "user_id",
"#user_relation": 'user_relation'
},
ExpressionAttributeValues: {
":user_id": "1234",
":user_relation": "followed-by"
}
}