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

support userId in donation schema #373

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

Fattimo
Copy link
Member

@Fattimo Fattimo commented Nov 6, 2020

added userId in donation schema. changed donation typing in types. modified method logDonation to take a userId as well. corrected misspelling of donation

@Fattimo Fattimo linked an issue Nov 6, 2020 that may be closed by this pull request
nonprofitId
}: DonationType): Promise<void> {
await Mongo();

const nonprofit = await Nonprofit.findOne({ _id: nonprofitId });
const user = await Donation.findOne({ _id: userId }); // TODO: Don't allow front end to pass null resulting userId
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this should be User.findOne right? Also right now we haven't decided if all Donations require a user ID, so could you make necessary changes to the Mongoose schema and the types in utils.ts to support null user ID or make user ID optional?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a user ID is specified and there is no user with that ID, we should throw an error, just like on line 22 we throw an error if the nonprofit doesn't exist.

@github-actions
Copy link

github-actions bot commented Nov 13, 2020

Deploy preview for gen-soln ready!

✅ Preview
https://gen-soln-i13jkzqbu.vercel.app

Built with commit e3c3005.
This pull request is being automatically deployed with vercel-action

Copy link
Collaborator

@PC98 PC98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of minor things, but tbh Matt it's okay if you don't do this now; we won't need this task for this semester's demo

await Mongo();

const nonprofit = await Nonprofit.findOne({ _id: nonprofitId });
const user = await User.findOne({ _id: userId }); // TODO: Don't allow front end to pass null resulting userId
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of things:
can we do this and line 20 in parallel, using Promise.all?

can we modify line 27 to not throw the error if userId equals the empty string (as you have done in DonationPageForm.tsx), just temprarily? Because otherwise, donations will fail when DMS team is testing their UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[VMS] Modify donation schema to include user-id
2 participants