Created
June 5, 2018 11:46
-
-
Save daniele-zurico/963d3c5ac9e05813b776846b001e3910 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { User } from "../models/users"; | |
import { Types } from "mongoose"; | |
const userController = { | |
addUser: (root: any, args: any) => { | |
const user = new User(args); | |
return user.save(); | |
}, | |
deleteUser: (root: any, args: any) => User.deleteOne({ _id: args.id }), | |
updateUser: (root: any, args: any) => { | |
const tempUser = { ...args }; | |
delete tempUser.id; | |
return User.updateOne({ _id: args.id }, { $set: tempUser }); | |
}, | |
users: (root: any, args: any) => User.find({}), | |
user: (token: string) => User.find({ token: token }), | |
login: (root: any, args: any) => userController.addUser(root, args) | |
}; | |
export { userController }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment