11import connector from "#models/databaseUtil" ;
22
33const accreditationSchema = {
4- uid : { type : String , unique : true , required : true } ,
5- accreditationName : { type : String , required : true } ,
6- agencyName : { type : String , required : true } ,
7- dateofAccreditation : { type : Date , required : true } ,
8- dateofExpiry : { type : Date , required : true }
4+ uid : { type : String , unique : true , required : true } ,
5+ accreditationName : { type : String , required : true } ,
6+ agencyName : { type : String , required : true } ,
7+ dateofAccreditation : { type : Date , required : true } ,
8+ dateofExpiry : { type : Date , required : true } ,
99} ;
1010
11- const Accreditation = new connector . model ( ' Accreditation' , accreditationSchema ) ;
11+ const Accreditation = new connector . model ( " Accreditation" , accreditationSchema ) ;
1212
1313async function remove ( filter ) {
14- const res = await Accreditation . findOneAndDelete ( filter ) ;
15- return res ;
14+ const res = await Accreditation . findOneAndDelete ( filter ) ;
15+ return res ;
1616}
1717
18- async function create ( uid , accreditationName , agencyName , dateofAccreditation , dateofExpiry ) {
19- const accreditation = new Accreditation ( {
20- accreditationName,
21- agencyName,
22- uid,
23- dateofAccreditation,
24- dateofExpiry
25- } ) ;
26- const accreditationDoc = await accreditation . save ( ) ;
27- return accreditationDoc ;
18+ async function create ( uid , accreditationName , agencyName , dateofAccreditation , dateofExpiry ) {
19+ const accreditation = new Accreditation ( {
20+ accreditationName,
21+ agencyName,
22+ uid,
23+ dateofAccreditation,
24+ dateofExpiry,
25+ } ) ;
26+ const accreditationDoc = await accreditation . save ( ) ;
27+ return accreditationDoc ;
2828}
2929
3030async function read ( filter , limit = 1 ) {
31- const accreditationData = await Accreditation . find ( filter ) . limit ( limit ) ;
32- return accreditationData ;
31+ const accreditationData = await Accreditation . find ( filter ) . limit ( limit ) ;
32+ return accreditationData ;
3333}
3434
3535async function update ( filter , updateObject ) {
36- const accreditation = await Accreditation . findOneAndUpdate ( filter , updateObject , { new : true } ) ;
37- return accreditation ;
36+ const accreditation = await Accreditation . findOneAndUpdate ( filter , updateObject , { new : true } ) ;
37+ return accreditation ;
3838}
3939
4040export default {
41- create, read, update, remove
42- } ;
41+ create, read, update, remove,
42+ } ;
0 commit comments