mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-24 09:39:35 +02:00
* registration/onboarding page * show only if in split test group * rate limiter, skip errors * fix storybook logo * remove skip payload * fix typos * prettier * store ODC form results in onboardingDataCollection * add userId * prettier * pick what properties should be stored * remove unused props * remove userId index * update user profile * update user profile * use setOp * added test * remove userId from schema * clean after user delete * mock unit test * limit to 255 chars * updatedAt field * prettier * firstName, lastName as separate vars * move subscribe at the end * check if user exists GitOrigin-RevId: 6d76927e97b5f4ed664ffb9b8806b3516c77eb9b
46 lines
958 B
JavaScript
46 lines
958 B
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,
|
|
updatedAt,
|
|
}) {
|
|
const odc = await OnboardingDataCollection.findOneAndUpdate(
|
|
{ _id: userId },
|
|
{
|
|
firstName,
|
|
lastName,
|
|
usedLatex,
|
|
primaryOccupation,
|
|
updatedAt,
|
|
},
|
|
{ upsert: true }
|
|
)
|
|
|
|
return odc
|
|
}
|
|
|
|
function deleteOnboardingDataCollection(id) {
|
|
return OnboardingDataCollection.deleteOne({ _id: id })
|
|
}
|
|
|
|
module.exports = {
|
|
getOnboardingDataCollection,
|
|
upsertOnboardingDataCollection,
|
|
deleteOnboardingDataCollection,
|
|
}
|