1let AWS = require('aws-sdk');
2let util = require('util');
3
4AWS.config.update({
5 region: 'us-east-1'
6});
7
8let connection = new AWS.DynamoDB.DocumentClient();
9
10let params = {
11 TableName: 'user_details',
12 KeyConditionExpression: 'user_id = :user_id and user_relation begins_with :user_relation',
13 ExpressionAttributeValues: {
14 ':user_id': "1234",
15 ':user_relation': "followed-by"
16 }
17};
18
19console.log('getQuery Params => ', params);
20let dynamoDb = util.promisify(connection.query).bind(connection);
21let results = await dynamoDb(params);
22console.log('results => ', results);
23
1const params = {
2 TableName: 'user_details',
3 KeyConditionExpression: '#user_id = :user_id and begins_with(#user_relation, :user_relation)',
4 ExpressionAttributeNames:{
5 "#user_id": "user_id",
6 "#user_relation": 'user_relation'
7 },
8 ExpressionAttributeValues: {
9 ":user_id": "1234",
10 ":user_relation": "followed-by"
11 }
12}
13