@@ -7,7 +7,13 @@ const userSchema = {
77 emailId : { type : String , unique : true , required : true } ,
88 password : { type : String , required : true } ,
99 uid : { type : String , unique : true , required : true } ,
10- userType : { type : String , required : true } ,
10+ userType : {
11+ type : String ,
12+ required : true ,
13+ enum : [ "ADMIN" , "FACULTY" , "EMPLOYEE" , "STUDENT" ] ,
14+ default : "ADMIN" ,
15+ // for now we are keeping the default usertype as ADMIN
16+ } ,
1117} ;
1218
1319const User = connector . model ( "User" , userSchema ) ;
@@ -18,9 +24,7 @@ async function remove(filter) {
1824}
1925
2026async function create ( userData ) {
21- const {
22- name, password, emailId, uid, userType,
23- } = userData ;
27+ const { name, password, emailId, uid, userType } = userData ;
2428 const hashedPassword = await hashPassword ( password ) ;
2529 const user = new User ( {
2630 name,
@@ -39,10 +43,17 @@ async function read(filter, limit = 1) {
3943}
4044
4145async function update ( filter , updateObject , options = { multi : true } ) {
42- const updateResult = await User . updateMany ( filter , { $set : updateObject } , options ) ;
46+ const updateResult = await User . updateMany (
47+ filter ,
48+ { $set : updateObject } ,
49+ options ,
50+ ) ;
4351 return updateResult . acknowledged ;
4452}
4553
4654export default {
47- create, read, update, remove,
55+ create,
56+ read,
57+ update,
58+ remove,
4859} ;
0 commit comments