title | date |
---|---|
Functions of Database Operations |
11/11/2021 |
This function is used to create sub-document profile
for the user with userId
, All fields need to match the type specified in DB_proposal. It will return newly created profile
.
The following is one example:
"_id": "7b7997a2-c0d2-4f8c-b27a-6a1d4b5b6310",
"photo": "one url",
"gender": "m",
"city": "Hoboken",
"state": "NJ",
"experience":[{"title":"Maintenance Engineer", "employment type": "full time",
"Company name":"Apple","start date": "08/05/2017", "end date": "08/05/2018"}]
"education":[
{"school":"xxx university", "field of study":"computer science",
"degree":"master of science",
"start date": "08/05/2010", "end date": "08/05/2014"}]
"skills":["Java", "JS"]
"languages":["english"]
"tags":["SDE","DS"]
Used to create an account for user:
- all the fields must be valid except for
profile
. - For
profile
, if it's a pdf, we will use functions in package to parse it, and then usecreateProfile
to create a profile. Ifprofile
is empty, set it with an empty object. jobs
andfavour
will be initialized with empty arrays.- password must be encoded and then be saved to database. (encode and decode function to be determined later)
One example:
"_id": "7b7997a2-c0d2-4f8c-b27a-6a1d4b5b6310",
"email": "[email protected]",
"phone": "848-242-6666",
"firstName": "Liam",
"lastName": "James",
"password": "$2a$08$XdvNkfdNIL8F8xsuIUeSbNOFgK0M0iV5HOskfVn7.PWncShU.O",
"jobs”: [],
"profile": ["profile1"]
"favor": []
updateProfile(profileId, userId, photo, gender, city, state, experience, education, skills, languages, tags)
Used to update the sub-document profile
of users with profileId
. The logic should be the same with function createProfile
.
- This function will update all the mandatory required data of this
user
currently in the database - All fields need to have valid values.
- If the removal succeeds, return the name of the
user
and the text " has been successfully deleted!" - Also update the job under recruiter collection with this
jobId
: remove theuserId
fromapplicantId
.
- Add this
jobId
to user'sjobs
field, and itsstatus
should bepending
. - Cannot apply jobs that already be applied.
- Also update the job under recruiter collection with this
jobId
: add theuserId
toapplicantId
.
- Add this
jobId
to user'sfavour
field. - Cannot save jobs that already be saved.
- remove this
jobId
from user'sjobs
field - Also update the job under recruiter collection with this
jobId
: remove theuserId
fromapplicantId
.
Return the status
of this jobId
.
Return all of jobs along with their status
.
When given an id, this function will return a user from the database.
Return all of the users from the database.
This function is used to create sub-document profile
for the recruiter with userId
, All fields need to match the type specified in DB_proposal. It will return newly created profile
.
Used to create an account for user:
- all the fields must be valid except for
profile
. - if
profile
is empty, set it with empty object. - For
profile
, it should be an object(all fields must be valid) and we usecreateProfile
to help us create the recruiter's profile. jobs
will be initialized with empty arrays.- password must be encoded and then be saved to database. (encode and decode function to be determined later)
- will return newly created recruiter info.
-
All the fields must match fields in DB_proposal, except for
payRange
andcompanyPic
, they are optional features. -
If
payRange
orcompanyPic
are not given, set it with empty string. -
details
should be an object, it's a sub-document of thisjob
."details": { "summary":"This is a abc company", "description":"This a devops role your responsibilities will be abc", "required":["Java","Mongodb"], "benefits":"you will get travelling allowance,insurance etc." },
-
Automatically set
postDate
to today's date andposter
to the recruiter. -
Return the newly added
job
.
Example of a job:
"_id": "7b7997a2-c0d2-4f8c-b27a-6a1d4b5b6310",
"title":"Software development summer 2022 internship"
"type": "internship",
"company: "Stevens",
"poster": "get it from recruiter id from recruiter collection",
"contact": "stevens.edu",
"city": "Hoboken",
"state": "NJ",
“postDate”: "today's date in MM/DD/YYYY,
"expiryDate":"MM/DD/YYY"
"details": {
"summary":"This is a abc company",
"description":"This a devops role your responsibilities will be abc",
"required":["Java","Mongodb"],
"benefits":"you will get travelling allowance,insurance etc."
},
"pay range":" 50 - 100 $ PER HOUR"
"companyPic": "image/pdf url"
updateJob(jobId, title, type, company, contact, city, state, expiryDate, details, payRange, companyPic)
Similar with post
.
- Remove all the applicants applied with this job.
- Remove saved jobs with this id
- Remove this job.
Recursively use removeJob(jobId)
.
remove
will take the following steps:
- With this
id
, first find thejobs
field, then find theapplicantId
underjobs
, remove these applicants applied jobs inuser
collection. - Remove jobs posted by this recruiter from
job
collection. (Step 1 and step 2 can useremoveAllJob
) - Remove recruiter with this
id
fine. - If the removal succeeds, return the name of the
user
and the text " has been successfully deleted!".
//To be discussed later
change the status this job under applicant's jobs
to accepted
change the status this job under applicant's jobs
to "rejected"
This part will be covered in lecture 10, to be added later.