GithubHelp home page GithubHelp logo

error connecting about dynamo-types HOT 11 CLOSED

sanchaysdn avatar sanchaysdn commented on May 30, 2024
error connecting

from dynamo-types.

Comments (11)

breath103 avatar breath103 commented on May 30, 2024

I'm not quite sure what you expecting for "example" since you can find that on readme.md
Or are you refering TS setting or AWS settings.. or something like that?
For specific error resolving, please provide detail of error you're getting
@sanchaysdn

from dynamo-types.

sanchaysdn avatar sanchaysdn commented on May 30, 2024

Actually, when I am following a documentation I am getting an error : Missing region & I am not sure where to put the connection settings

from dynamo-types.

sanchaysdn avatar sanchaysdn commented on May 30, 2024

below is my code `import {
Config,
Decorator,
Query,
Table
} from 'dynamo-types';

@Decorator.Table({ name: 'prod-Card1' })
export class Card extends Table {
@Decorator.Attribute()
id: number;

@Decorator.Attribute()
title: string;

@Decorator.Attribute({ timeToLive: true })
expiresAt: number;

// tslint:disable-next-line:member-ordering
@Decorator.FullPrimaryKey('id', 'title')
static readonly primaryKey: Query.FullPrimaryKey<Card, number, string>;

// tslint:disable-next-line:member-ordering
@Decorator.Writer()
static readonly writer: Query.Writer<Card>;

test(): void {
    // tslint:disable-next-line:no-console
    console.log('Coming here @@@');
    console.log(Config);
}

}
Card.createTable();`

from dynamo-types.

sanchaysdn avatar sanchaysdn commented on May 30, 2024

mport * as AWS from 'aws-sdk'; AWS.config.update({ region: 'eu-west-1' }); import { CrudService } from '../../services/crudService'; import { Card } from './applications.schema'; const dynamoDb = new AWS.DynamoDB.DocumentClient({ region: 'eu-west-1', endpoint: 'http://localhost:8000' }); export class ApplicationsRepository { card = new Card(); async testORM(event) { this.card.test(); } }

from dynamo-types.

breath103 avatar breath103 commented on May 30, 2024

So what you need is AWS Region setting. Which is handled by aws-sdk, Refer
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-region.html
in short, use AWS_REGION environment variable, along with AWS_ACCESS_KEY and TOKEN

from dynamo-types.

sanchaysdn avatar sanchaysdn commented on May 30, 2024

As you can see my code above I have set that already.

from dynamo-types.

breath103 avatar breath103 commented on May 30, 2024

That doesn't guarantee (and this case surely not) to be shared across whole node.js application. Only AWS_REGION environment is clearly guaranteed to be used as a default setting across whole given process

from dynamo-types.

breath103 avatar breath103 commented on May 30, 2024

It's kinda confusing to me that what were you trying to do since new Card() doesn't really save record to DynamoDB obviously, but

bash> AWS_REGION=eu-west-1 node
import { CrudService } from '../../services/crudService'; 
import { Card } from './applications.schema'; 

export class ApplicationsRepository { 
  async testORM() { 
    const card = new Card(); 
    card.id = 100;
    await card.save();
    return card;
  } 
}

new ApplicationsRepository().testORM().then(console.log, console.log)

this should work just fine. you don't have to do anything like making DynamoDB client..etc.

from dynamo-types.

sanchaysdn avatar sanchaysdn commented on May 30, 2024

Ok we are little close in using the ORM can you please suggest how i can create a Table using createTable().

from dynamo-types.

sanchaysdn avatar sanchaysdn commented on May 30, 2024

it worked now thanks. But how can I retrieve all the data.

from dynamo-types.

sanchaysdn avatar sanchaysdn commented on May 30, 2024

Thanks @breath103 everything seems to working now. I am closing this issue.

from dynamo-types.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.