Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // UserRepository interface implemented instead of
- // directly interfacing mongo db client
- //
- async function updateUserService ({userRepository, updateParams}) {
- const { userId, userName, userEmail } = updateParams
- // validate params
- if (!userId || !userName || !userEmail) {
- throw new InvalidParamsException('Missing required params')
- }
- const user = await userRepository.getById(userId)
- const updatedUser = updateUser(user, {
- userName,
- userEmail
- })
- await userRepository.save(updatedUser)
- }
Add Comment
Please, Sign In to add comment