dynamodb
dynamodb copied to clipboard
How to scan data from existing table
I have a user table already defined, I just need to access its data using scan.
import * as dynamo from 'dynamodb';
async fetchUser(): Promise<any> {
try {
dynamo.AWS.config.update({ accessKeyId: process.env.ACCESS_KEY_ID, secretAccessKey: process.env.SECRET_KEY, region: process.env.REGION });
const user = dynamo.define('User', {
hashKey: 'email',
tableName: 'user'
});
return await user.scan()
.limit(10)
.exec();
} catch (error) {
throw error;
}
}
I'm not getting any data, am I doing anything wrong here. There is nothing documented for fetching data from existing table. Kindly assist.......!!
return await user
.scan()
.limit(10)
.exec()
.promise();