Last active
January 15, 2022 07:13
-
-
Save neerajkumar161/b5e3e6e1ee9384f3d0c65d786ab46709 to your computer and use it in GitHub Desktop.
/src/resolvers/update-user.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { userModel } from '../models/user' | |
export const updateUserResolver = async (parent: any, args: any, context: any) => { | |
let user = await userModel.findOne({email: args.email}).lean() | |
if (!user) throw new Error('User not exists!') | |
const updateUser = {email: user.email, ...args} | |
user = await userModel | |
.findByIdAndUpdate(user._id, updateUser, {new: true}) | |
.lean() | |
return user | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment