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

Add dynamoose-decorator for support typescript schema #1657

Closed
wants to merge 3 commits into from

Conversation

changmyeong
Copy link

@changmyeong changmyeong commented Jan 20, 2024

Summary: Adding dynamoose-decorator for support typescript schema

Code sample:

Schema

import { Item } from 'dynamoose/dist/Item';
import {
  HashKey,
  Attribute,
  Required,
  Index,
  CreatedAt,
  UpdatedAt,
  Model,
  Storage,
  getModel,
} from 'dynamoose-decorator';

@Model({ throughput: 'ON_DEMAND', waitForActive: false })
class User extends Item {
  @HashKey()
  @Attribute()
  id: string;

  @Index({ name: 'emailIndex' })
  @Required()
  @Attribute()
  email: string;

  @Index({ name: 'nameIndex' })
  @Required()
  @Attribute()
  name: string;

  @Index({ name: 'companyAndScoreIndex', rangeKey: 'score' })
  @Attribute()
  company: string;

  @Attribute()
  score: number;

  @Storage('milliseconds')
  @CreatedAt()
  @Attribute()
  createdAt: Date;

  @Storage('milliseconds')
  @UpdatedAt()
  @Attribute()
  updatedAt: Date;
}

Model

const UserModel = getModel(User)

Usage

const user = new UserModel();
user.id = 'bf02318d-4029-4474-a7a0-e957eb176d75';
user.email = 'test@dynamoose.com';
user.name = 'DYNAMOOSE';
user.company = 'Amazon';
user.score = 3;

await user.save();

GitHub linked issue:

Discussions: #1656

Other information:

Type (select 1):

  • Bug fix
  • Feature implementation
  • Documentation improvement
  • Testing improvement
  • Test added to report bug (GitHub issue #---- @---)
  • Something not listed here

Is this a breaking change? (select 1):

  • 🚨 YES 🚨
  • No
  • I'm not sure

Is this ready to be merged into Dynamoose? (select 1):

  • Yes
  • No

Are all the tests currently passing on this PR? (select 1):

  • Yes
  • No

Other:

  • I have read through and followed the Contributing Guidelines
  • I have searched through the GitHub pull requests to ensure this PR has not already been submitted
  • I have updated the Dynamoose documentation (if required) given the changes I made
  • I have added/updated the Dynamoose test cases (if required) given the changes I made
  • I agree that all changes made in this pull request may be distributed and are made available in accordance with the Dynamoose license
  • All of my commits and commit messages are detailed, explain what changes were made, and are easy to follow and understand
  • I have filled out all fields above

Copy link
Contributor

github-actions bot commented Jan 20, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@changmyeong
Copy link
Author

I dedicate any and all copyright interest in this software to the public domain. I make this dedication for the benefit of the public at large and to the detriment of my heirs and successors. I intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

@changmyeong changmyeong changed the title Adding dynamoose-decorator for support typescript schema Add dynamoose-decorator for support typescript schema Jan 27, 2024
Copy link
Contributor

github-actions bot commented Feb 4, 2024

This pull request is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 3 days.

@fishcharlie
Copy link
Member

Closing in favor of 1e5b220. This PR heavily indicates that Dynamoose endorses dynamoose-decorator, which isn't the case. So I decided to go in favor of the option discussed with creating a new page for these resources. Since it is a 3rd party resource a separate page seems appropriate. I don't want users to get confused and think that dynamoose-decorator is part of Dynamoose itself or anything like that.

@fishcharlie fishcharlie closed this Feb 4, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants