Implementar modulo de Roles y Usuarios
This commit is contained in:
46
backend/src/modules/user/user.service.ts
Normal file
46
backend/src/modules/user/user.service.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import userModel from "./user.model";
|
||||
|
||||
export class UserService {
|
||||
|
||||
async getAll() {
|
||||
|
||||
return await userModel
|
||||
.find()
|
||||
.populate("roleId");
|
||||
}
|
||||
|
||||
async getById(
|
||||
id:string
|
||||
) {
|
||||
return await userModel
|
||||
.find()
|
||||
.populate("roleId");
|
||||
}
|
||||
|
||||
async create(
|
||||
data:any
|
||||
) {
|
||||
return await userModel.create(data);
|
||||
}
|
||||
|
||||
async update(
|
||||
id:string,
|
||||
data:any
|
||||
) {
|
||||
return await userModel.findByIdAndUpdate(
|
||||
id,
|
||||
data,
|
||||
{
|
||||
new:true
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async delete(
|
||||
id:string
|
||||
) {
|
||||
return await userModel.findByIdAndDelete(
|
||||
id
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user