mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-28 19:41:33 +02:00
64 lines
1.3 KiB
JavaScript
64 lines
1.3 KiB
JavaScript
const {
|
|
OnboardingDataCollection,
|
|
} = require('../../models/OnboardingDataCollection')
|
|
const OError = require('@overleaf/o-error')
|
|
|
|
async function getOnboardingDataCollection(userId) {
|
|
try {
|
|
return await OnboardingDataCollection.findOne({ _id: userId }).exec()
|
|
} catch (error) {
|
|
throw OError.tag(error, 'Failed to get OnboardingDataCollection')
|
|
}
|
|
}
|
|
|
|
async function upsertOnboardingDataCollection({
|
|
userId,
|
|
firstName,
|
|
lastName,
|
|
usedLatex,
|
|
primaryOccupation,
|
|
companyDivisionDepartment,
|
|
companyJobTitle,
|
|
governmentJobTitle,
|
|
institutionName,
|
|
otherJobTitle,
|
|
nonprofitDivisionDepartment,
|
|
nonprofitJobTitle,
|
|
role,
|
|
subjectArea,
|
|
updatedAt,
|
|
}) {
|
|
const odc = await OnboardingDataCollection.findOneAndUpdate(
|
|
{ _id: userId },
|
|
{
|
|
firstName,
|
|
lastName,
|
|
usedLatex,
|
|
primaryOccupation,
|
|
companyDivisionDepartment,
|
|
companyJobTitle,
|
|
governmentJobTitle,
|
|
institutionName,
|
|
otherJobTitle,
|
|
nonprofitDivisionDepartment,
|
|
nonprofitJobTitle,
|
|
role,
|
|
subjectArea,
|
|
updatedAt,
|
|
},
|
|
{ upsert: true }
|
|
)
|
|
|
|
return odc
|
|
}
|
|
|
|
function deleteOnboardingDataCollection(id) {
|
|
return OnboardingDataCollection.deleteOne({ _id: id })
|
|
}
|
|
|
|
module.exports = {
|
|
getOnboardingDataCollection,
|
|
upsertOnboardingDataCollection,
|
|
deleteOnboardingDataCollection,
|
|
}
|