You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Part 1: Creating the User and VolunteerDetails Schemas
We have defined a partial User schema in schema.prisma. A User will encompass both Volunteer and Admin roles, which will be differentiated by the “Role” field. However, a Volunteer will have many additional fields that an Admin will not have. Because of this, we think it will be best to create a schema called “VolunteerDetails” that will have a one-to-one relation with the User schema, which will contain the additional fields that Volunteers have.
So your task is to add the remaining fields to the User schema and create a new VolunteerDetails schema:
Role
Last Name
VolunteerDetails Schema:
First Name
Last Name
Email
Are they over the age of 14?
Country
Address
City
State
ZIP Code
If they have a driver’s license?
Do you speak Spanish?
Volunteer Type (Individual Volunteer, Community Group, Corporate Team, Youth Group) (Reasoning for volunteering? + Other/Followup)
Days available
Time of day available (daytime/evening/anytime)
On what basis they plan to volunteer (one-time/weekly/biweekly/monthly, etc)
If you're not too familiar with Prisma, the schema fields that are already defined should help you, and you should definitely read up on the documentation to learn more about the syntax: https://www.prisma.io/docs/orm/prisma-schema/overview
Part 2: Creating the User API Routes
After doing that, we need to create API routes to update (PUT) and delete (DELETE) a User. If you go into src/app/api/user/route.ts, you can see that we made an example POST request for the current User Type. We also have a function called addUser in src/app/api/user/route.client.ts that calls the POST request. Try to follow a similar logic to this when implementing your own routes in the same files.
This might seem like a lot, but we’re here for you so don’t stress! Focus first on finishing the schemas. After checking in with us, you can move onto creating the API routes! If you ever need any help or are stuck on any new terms or concepts make sure to reach out whenever! :)
Testing
Like we said before, once you get the schema done, make sure to reach out to us so we can go over it together!
To test your backend routes and APIs, you can call the API on the frontend with a simple button. You can hard code data and pass it into your API, like the test button example we have in src/components/ExampleButton.tsx. Go to MongoDB Atlas and see if your operations happened as expected.
Once you have thoroughly tested, feel free to make a PR (Pull Request).
The text was updated successfully, but these errors were encountered:
Description
Part 1: Creating the User and VolunteerDetails Schemas
We have defined a partial User schema in
schema.prisma
. A User will encompass both Volunteer and Admin roles, which will be differentiated by the “Role” field. However, a Volunteer will have many additional fields that an Admin will not have. Because of this, we think it will be best to create a schema called “VolunteerDetails” that will have a one-to-one relation with the User schema, which will contain the additional fields that Volunteers have.So your task is to add the remaining fields to the User schema and create a new VolunteerDetails schema:
VolunteerDetails Schema:
If you're not too familiar with Prisma, the schema fields that are already defined should help you, and you should definitely read up on the documentation to learn more about the syntax: https://www.prisma.io/docs/orm/prisma-schema/overview
Part 2: Creating the User API Routes
After doing that, we need to create API routes to update (PUT) and delete (DELETE) a User. If you go into
src/app/api/user/route.ts
, you can see that we made an example POST request for the current User Type. We also have a function calledaddUser
insrc/app/api/user/route.client.ts
that calls the POST request. Try to follow a similar logic to this when implementing your own routes in the same files.This might seem like a lot, but we’re here for you so don’t stress! Focus first on finishing the schemas. After checking in with us, you can move onto creating the API routes! If you ever need any help or are stuck on any new terms or concepts make sure to reach out whenever! :)
Testing
Like we said before, once you get the schema done, make sure to reach out to us so we can go over it together!
To test your backend routes and APIs, you can call the API on the frontend with a simple button. You can hard code data and pass it into your API, like the test button example we have in
src/components/ExampleButton.tsx
. Go to MongoDB Atlas and see if your operations happened as expected.Once you have thoroughly tested, feel free to make a PR (Pull Request).
The text was updated successfully, but these errors were encountered: