-
Notifications
You must be signed in to change notification settings - Fork 19
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
Create transactions resource #92
Conversation
…troller, module, repository, and service
…lass-transformer (npm)
|
||
export class CreateTransactionDto { | ||
@IsNotEmpty() | ||
donater_user: User; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix:
Should be:
@IsNotEmpty()
donater_user_id: number;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, are you sure?
would nest know to add a .donater
attr or function to the transation model then? now that i think about it, idk how to control the model in nest, like if i wanted to write a custom function like asset.close()
(that updates the status to all the transactions related to that asset, how would i do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at your example,
This:
curl -X POST localhost:3001/api/assets \
-H "Content-Type: application/json" \
-d '{ "title": "thing 1", "description": "its a thing", "type": "donation", "quantity": "1",
"poster": { "first_name":"test", "last_name":"user", "email":"[email protected]", "id": "18" } }'
can be replaced by example below, if you change the createDto to use poster_id instead of a whole new poster object. The return type will be whatever the repository returns (transactionEntity
):
curl -X POST localhost:3001/api/assets \
-H "Content-Type: application/json" \
-d '{ "title": "thing 1", "description": "its a thing", "type": "donation", "quantity": "1",
"poster_id": 18 }'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, you would have to implement something like: create-transactions-resource...sample/create-transactions-resource
Also, if you are going to stick with the getTransactionsDto
as the get all filtering model, there is some funky formatting we have to do in the front end to send the nested object in the url query params. See this
@IsOptional() | ||
donater_organization: Organization; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix:
Should be:
@IsNotEmpty()
donater_organization_id: number;
@IsOptional() | ||
recipient: Organization; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, only the foreign key is required
@IsNotEmpty({ message: 'asset_id is required' }) | ||
asset: Asset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, only the foreign key is required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments
@IsOptional() | ||
@IsNotEmpty() | ||
created_date: Date; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't these cancel each other?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totally 😆
removed altogether because the default value should be used and so we don't need to pass anything in
Dev Summary
adding the transactions resource here. this is a key part of our data model. this is how users will claim/give assets.
this includes the standard parts of a new resource (controller, service, module, entity, dtos, etc.)
Test Plan
repro steps:
npm run start:dev
expect there to be one
then get all transactions again and expect it to be empty
Resources