Last active
January 15, 2022 07:13
-
-
Save neerajkumar161/fa2722e92a962165977d782f4e2eed67 to your computer and use it in GitHub Desktop.
/src/resolvers/delete-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 deleteUserResolver = async (parent: any, args: any, context: any) => { | |
let user = await userModel.findOne({email: args.email}) | |
if (!user) throw new Error('User not exists!') | |
await userModel.findOneAndRemove({_id: user._id}) | |
return {message: 'User Deleted!'} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment