You've already forked pigallery2
mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-07-15 01:24:25 +02:00
implementing mongoose managers
This commit is contained in:
45
backend/model/mongoose/MongoUserManager.ts
Normal file
45
backend/model/mongoose/MongoUserManager.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import {User} from "../../../common/entities/User";
|
||||
import {IUserManager} from "../IUserManager";
|
||||
import {DatabaseManager} from "./DatabaseManager";
|
||||
|
||||
export class MongoUserManager implements IUserManager{
|
||||
|
||||
private UserModel;
|
||||
|
||||
constructor(){
|
||||
this.UserModel = DatabaseManager.getInstance().getModel('user',{
|
||||
name:String,
|
||||
email:{ type: String, index: { unique: true }},
|
||||
password:String,
|
||||
role:Number
|
||||
});
|
||||
}
|
||||
|
||||
public findOne(filter,cb:(error: any,result:User) => void){
|
||||
return this.UserModel.findOne(filter,function (err, result) {
|
||||
return cb(err, result);
|
||||
});
|
||||
}
|
||||
|
||||
public find(filter,cb:(error: any,result:Array<User>) => void){
|
||||
this.UserModel.find(filter,function (err, result) {
|
||||
return cb(err, result);
|
||||
});
|
||||
}
|
||||
|
||||
public createUser(user,cb:(error: any,result:User) => void){
|
||||
this.UserModel.create(user,cb);
|
||||
}
|
||||
|
||||
public deleteUser(id:number,cb:(error: any) => void){
|
||||
this.UserModel.remove({id:id},cb);
|
||||
}
|
||||
|
||||
public changeRole(request:any,cb:(error: any,result:string) => void){
|
||||
throw new Error("not implemented"); //TODO: implement
|
||||
}
|
||||
public changePassword(request:any,cb:(error: any,result:string) => void){
|
||||
throw new Error("not implemented"); //TODO: implement
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user