| 123456789101112131415161718192021 |
- const Project = require('../models/project');
- class StudentService {
- static async getAll(filter) {
- return Project.find(filter);
- }
- static async create(StudentData) {
- StudentService.validateModel(StudentData);
- return new Project(StudentData).save();
- }
- static validateModel(data) {
- const project = new Project(data);
- const validation = project.validateSync();
- if (validation)
- throw validation.errors
- }
- }
- module.exports = StudentService;
|