Skip to content

How to scan data from existing table #93

@sandesh-bhoir

Description

@sandesh-bhoir

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions