Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to scan data from existing table #93

Open
sandesh-bhoir opened this issue May 24, 2021 · 1 comment
Open

How to scan data from existing table #93

sandesh-bhoir opened this issue May 24, 2021 · 1 comment

Comments

@sandesh-bhoir
Copy link

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.......!!

@steveluscher
Copy link

return await user
  .scan()
  .limit(10)
  .exec()
  .promise();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants