-
Notifications
You must be signed in to change notification settings - Fork 70
/
user-tenant-prefs.repository.ts
45 lines (43 loc) · 1.48 KB
/
user-tenant-prefs.repository.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2023 Sourcefuse Technologies
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
import {Getter, inject} from '@loopback/core';
import {BelongsToAccessor, juggler, repository} from '@loopback/repository';
import {
DefaultUserModifyCrudRepository,
IAuthUserWithPermissions,
} from '@sourceloop/core';
import {AuthenticationBindings} from 'loopback4-authentication';
import {UserTenantDataSourceName} from '../keys';
import {UserTenant, UserTenantPrefs} from '../models';
import {UserTenantRepository} from './user-tenant.repository';
export class UserTenantPrefsRepository extends DefaultUserModifyCrudRepository<
UserTenantPrefs,
typeof UserTenantPrefs.prototype.id
> {
public readonly userTenant: BelongsToAccessor<
UserTenant,
typeof UserTenantPrefs.prototype.id
>;
constructor(
@inject(`datasources.${UserTenantDataSourceName}`)
dataSource: juggler.DataSource,
@repository.getter('UserTenantRepository')
protected userTenantRepositoryGetter: Getter<UserTenantRepository>,
@inject.getter(AuthenticationBindings.CURRENT_USER)
protected readonly getCurrentUser: Getter<
IAuthUserWithPermissions | undefined
>,
) {
super(UserTenantPrefs, dataSource, getCurrentUser);
this.userTenant = this.createBelongsToAccessorFor(
'userTenant',
userTenantRepositoryGetter,
);
this.registerInclusionResolver(
'userTenant',
this.userTenant.inclusionResolver,
);
}
}