UNPKG

express-api-cli

Version:

Cli tool for generating an express project. Instead of wasting extra time creating your project structure, start building right away

40 lines (34 loc) 701 B
import User from '../models/user.model'; //get all users export const getAllUsers = async () => { const data = await User.find(); return data; }; //create new user export const newUser = async (body) => { const data = await User.create(body); return data; }; //update single user export const updateUser = async (_id, body) => { const data = await User.findByIdAndUpdate( { _id }, body, { new: true } ); return data; }; //delete single user export const deleteUser = async (id) => { await User.findByIdAndDelete(id); return ''; }; //get single user export const getUser = async (id) => { const data = await User.findById(id); return data; };