File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -17,3 +17,46 @@ const departmentSchema = {
1717} ;
1818
1919const Department = connector . model ( 'Department' , departmentSchema ) ;
20+
21+ //for creating
22+ async function create (
23+ name ,
24+ acronym ,
25+ yearOfStarting ,
26+ accreditions ,
27+ infrastructures
28+ ) {
29+ const department = new Department ( {
30+ name,
31+ acronym,
32+ yearOfStarting,
33+ accreditions,
34+ infrastructures
35+ } ) ;
36+ const departmentDoc = await department . save ( ) ;
37+ return departmentDoc ;
38+ }
39+
40+ async function read ( filter , limit = 1 ) {
41+ const departmentData = await Department . find ( filter ) . limit ( limit ) ;
42+ return departmentData ;
43+ }
44+
45+ async function update ( filter , updateObject ) {
46+ const department = await Department . findOneAndUpdate ( filter , updateObject , {
47+ new : true ,
48+ } ) ;
49+ return department ;
50+ }
51+
52+ async function remove ( filter ) {
53+ const res = await Department . findOneAndDelete ( filter ) ;
54+ return res ;
55+ }
56+
57+ export default {
58+ create,
59+ read,
60+ update,
61+ remove,
62+ } ;
You can’t perform that action at this time.
0 commit comments