Year Routes
GET
/api/years/:plan_id
Gets a list of year objects for a given plan.
Name | Type | Description | |
---|---|---|---|
Params | plan_id | String | id of plan for which to get year ids from |
Output | Year[] | list of year ids from plan |
Sample output
[
{
"_id": {
"$oid": "61cce47ca2ec790004427205"
},
"courses": [],
"plan_id": [
{
"$oid": "61cce47ca2ec790004427200"
}
],
"name": "Freshman",
"user_id": "guestUser",
"year": 2021,
"expireAt": {
"$date": "2021-12-30T22:43:08.296Z"
},
"__v": 0
},
{
"_id": {
"$oid": "61cce47ca2ec790004427207"
},
"courses": [],
"plan_id": [
{
"$oid": "61cce47ca2ec790004427200"
}
],
"name": "Sophomore",
"user_id": "guestUser",
"year": 2022,
"expireAt": {
"$date": "2021-12-30T22:43:08.305Z"
},
"__v": 0
},
{
"_id": {
"$oid": "61cce47ca2ec790004427209"
},
"courses": [
{
"$oid": "61ccf7f4723b840004850ea3"
}
],
"plan_id": [
{
"$oid": "61cce47ca2ec790004427200"
}
],
"name": "Junior",
"user_id": "guestUser",
"year": 2023,
"expireAt": {
"$date": "2021-12-30T22:43:08.312Z"
},
"__v": 0
},
{
"_id": {
"$oid": "61cce47ca2ec79000442720b"
},
"courses": [],
"plan_id": [
{
"$oid": "61cce47ca2ec790004427200"
}
],
"name": "Senior",
"user_id": "guestUser",
"year": 2024,
"expireAt": {
"$date": "2021-12-30T22:43:08.321Z"
},
"__v": 0
},
{
"_id": {
"$oid": "61cd000b723b840004850eb7"
},
"courses": [],
"plan_id": [
{
"$oid": "61cd000b723b840004850eb5"
}
],
"name": "AP Equivalents",
"user_id": "guestUser",
"year": 2020,
"expireAt": {
"$date": "2021-12-31T00:40:43.334Z"
},
"__v": 0
}
]
POST
/api/years
Creates a new year based on a given name, plan_id, user_id, and year number. A year will be automatically added to the end of the year array of the plan object.
Name | Type | Description | |
---|---|---|---|
Body | name | String | name of year to create |
plan_id | String | id of plan for which to make year for | |
user_id | String | id of user for which to make year for | |
year | Number | numeric year value | |
Output | Year | Newly created year |
Sample Output
{
"_id": {
"$oid": "61cce47ca2ec79000442720b"
},
"courses": [],
"plan_id": [
{
"$oid": "61cce47ca2ec790004427200"
}
],
"name": "Senior",
"user_id": "guestUser",
"year": 2024,
"expireAt": {
"$date": "2021-12-30T22:43:08.321Z"
},
"__v": 0
}
PATCH
/api/years/changeOrder
Creates a new year based on a given name, plan_id, user_id, and year number.
Name | Type | Description | |
---|---|---|---|
Body | plan_id | String | id of plan for which to change year order for |
year_ids | String[] | array of new year ids order | |
Output | Plan | Newly updated plan |
Sample Output
[
{
"_id": {
"$oid": "61cce47ca2ec790004427205"
},
"courses": [],
"plan_id": [
{
"$oid": "61cce47ca2ec790004427200"
}
],
"name": "Freshman",
"user_id": "guestUser",
"year": 2021,
"expireAt": {
"$date": "2021-12-30T22:43:08.296Z"
},
"__v": 0
},
{
"_id": {
"$oid": "61cce47ca2ec790004427209"
},
"courses": [
{
"$oid": "61ccf7f4723b840004850ea3"
}
],
"plan_id": [
{
"$oid": "61cce47ca2ec790004427200"
}
],
"name": "Junior",
"user_id": "guestUser",
"year": 2023,
"expireAt": {
"$date": "2021-12-30T22:43:08.312Z"
},
"__v": 0
},
{
"_id": {
"$oid": "61cce47ca2ec790004427207"
},
"courses": [],
"plan_id": [
{
"$oid": "61cce47ca2ec790004427200"
}
],
"name": "Sophomore",
"user_id": "guestUser",
"year": 2022,
"expireAt": {
"$date": "2021-12-30T22:43:08.305Z"
},
"__v": 0
},
{
"_id": {
"$oid": "61cce47ca2ec79000442720b"
},
"courses": [],
"plan_id": [
{
"$oid": "61cce47ca2ec790004427200"
}
],
"name": "Senior",
"user_id": "guestUser",
"year": 2024,
"expireAt": {
"$date": "2021-12-30T22:43:08.321Z"
},
"__v": 0
}
]
PATCH
/api/years/updateName
Updates the name of a specific year. Updates plan name and the year field of its associated courses.
Name | Type | Description | |
---|---|---|---|
Body | name | String | new year name |
year_id | String | id of year to change name for | |
Output | Year | Newly updated year |
Sample Output
{
"_id": {
"$oid": "61cce47ca2ec79000442720b"
},
"courses": [],
"plan_id": [
{
"$oid": "61cce47ca2ec790004427200"
}
],
"name": "Senior",
"user_id": "guestUser",
"year": 2024,
"expireAt": {
"$date": "2021-12-30T22:43:08.321Z"
},
"__v": 0
}
DELETE
/api/years/:year_id
Deletes a year. By deleting a year, all associated courses are deleted from the database.
Name | Type | Description | |
---|---|---|---|
Params | year_id | String | id of year to delete |
Output | Year | deleted year |
Sample Output
{
"_id": {
"$oid": "61cce47ca2ec79000442720b"
},
"courses": [],
"plan_id": [
{
"$oid": "61cce47ca2ec790004427200"
}
],
"name": "Senior",
"user_id": "guestUser",
"year": 2024,
"expireAt": {
"$date": "2021-12-30T22:43:08.321Z"
},
"__v": 0
}