Skip to main content

Year Routes

GET /api/years/:plan_id

Gets a list of year objects for a given plan.

NameTypeDescription
Paramsplan_idStringid of plan for which to get year ids from
OutputYear[]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.

NameTypeDescription
BodynameStringname of year to create
plan_idStringid of plan for which to make year for
user_idStringid of user for which to make year for
yearNumbernumeric year value
OutputYearNewly 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.

NameTypeDescription
Bodyplan_idStringid of plan for which to change year order for
year_idsString[]array of new year ids order
OutputPlanNewly 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.

NameTypeDescription
BodynameStringnew year name
year_idStringid of year to change name for
OutputYearNewly 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.

NameTypeDescription
Paramsyear_idStringid of year to delete
OutputYeardeleted 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
}