Comments (11)
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.
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.
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.
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.
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.
As you can see my code above I have set that already.
from dynamo-types.
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.
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.
Ok we are little close in using the ORM can you please suggest how i can create a Table using createTable().
from dynamo-types.
it worked now thanks. But how can I retrieve all the data.
from dynamo-types.
Thanks @breath103 everything seems to working now. I am closing this issue.
from dynamo-types.
Related Issues (20)
- AWS_XRAY_CONTEXT_MISSING and AWS_XRAY_DAEMON_ADDRESS is set HOT 4
- batch write ignoring failed writes HOT 2
- Conditional updates? HOT 11
- Feature Request: Ability to specify type in decorator, to allow Class type HOT 2
- Rename the repo 'dynamo-types'? HOT 3
- CreateTable fails when using TTL field with local-dynamo HOT 5
- node version? HOT 5
- Is this project still maintained? HOT 2
- Scan on global secondary index? HOT 3
- Query.GlobalSecondayIndex.scan doesnโt pass IndexName HOT 1
- Add AWS config to documentation HOT 2
- Remove `Decorator` namespace HOT 1
- Table decorator: Create table if it does not exist HOT 1
- Improve documentation HOT 1
- Is there a way to update only part of a map? HOT 2
- Is there a way to apply filters expression on query HOT 1
- no initializer error HOT 2
- Increment value in DynamoDB table HOT 1
- updates on lists
- This repository will no longer be maintained. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dynamo-types.