@@ -11,11 +11,11 @@ import { UserScope } from './user.scope';
11
11
12
12
@Injectable ( )
13
13
export class UserRepo extends BaseRepo < User > {
14
- get entityName ( ) {
14
+ get entityName ( ) : typeof User {
15
15
return User ;
16
16
}
17
17
18
- async findById ( id : EntityId , populate = false ) : Promise < User > {
18
+ public async findById ( id : EntityId , populate = false ) : Promise < User > {
19
19
const user = await super . findById ( id ) ;
20
20
21
21
if ( populate ) {
@@ -26,7 +26,7 @@ export class UserRepo extends BaseRepo<User> {
26
26
return user ;
27
27
}
28
28
29
- async findByIdOrNull ( id : EntityId , populate = false ) : Promise < User | null > {
29
+ public async findByIdOrNull ( id : EntityId , populate = false ) : Promise < User | null > {
30
30
const user : User | null = await this . _em . findOne ( User , { id } ) ;
31
31
32
32
if ( ! user ) {
@@ -41,7 +41,7 @@ export class UserRepo extends BaseRepo<User> {
41
41
return user ;
42
42
}
43
43
44
- async findByExternalIdOrFail ( externalId : string , systemId : string ) : Promise < User > {
44
+ public async findByExternalIdOrFail ( externalId : string , systemId : string ) : Promise < User > {
45
45
const [ users ] = await this . _em . findAndCount ( User , { externalId } , { populate : [ 'school.systems' ] } ) ;
46
46
const resultUser = users . find ( ( user ) => {
47
47
const { systems } = user . school ;
@@ -50,7 +50,7 @@ export class UserRepo extends BaseRepo<User> {
50
50
return resultUser ?? Promise . reject ( ) ;
51
51
}
52
52
53
- async findForImportUser (
53
+ public async findForImportUser (
54
54
school : SchoolEntity ,
55
55
filters ?: ImportUserNameMatchFilter ,
56
56
options ?: IFindOptions < User >
@@ -71,23 +71,23 @@ export class UserRepo extends BaseRepo<User> {
71
71
return countedUsers ;
72
72
}
73
73
74
- async findByEmail ( email : string ) : Promise < User [ ] > {
74
+ public findByEmail ( email : string ) : Promise < User [ ] > {
75
75
// find mail case-insensitive by regex
76
76
const promise : Promise < User [ ] > = this . _em . find ( User , {
77
77
email : new RegExp ( `^${ email . replace ( / \W / g, '\\$&' ) } $` , 'i' ) ,
78
78
} ) ;
79
79
return promise ;
80
80
}
81
81
82
- async deleteUser ( userId : EntityId ) : Promise < number > {
82
+ public async deleteUser ( userId : EntityId ) : Promise < number > {
83
83
const deletedUserNumber = await this . _em . nativeDelete ( User , {
84
84
id : userId ,
85
85
} ) ;
86
86
87
87
return deletedUserNumber ;
88
88
}
89
89
90
- async getParentEmailsFromUser ( userId : EntityId ) : Promise < string [ ] > {
90
+ public async getParentEmailsFromUser ( userId : EntityId ) : Promise < string [ ] > {
91
91
const user : User | null = await this . _em . findOne ( User , { id : userId } ) ;
92
92
let parentsEmails : string [ ] = [ ] ;
93
93
if ( user !== null ) {
@@ -109,11 +109,11 @@ export class UserRepo extends BaseRepo<User> {
109
109
}
110
110
}
111
111
112
- saveWithoutFlush ( user : User ) : void {
112
+ public saveWithoutFlush ( user : User ) : void {
113
113
this . _em . persist ( user ) ;
114
114
}
115
115
116
- async flush ( ) : Promise < void > {
116
+ public async flush ( ) : Promise < void > {
117
117
await this . _em . flush ( ) ;
118
118
}
119
119
0 commit comments