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