1
1
import { Injectable , Logger } from '@nestjs/common' ;
2
2
import { EventEmitter2 } from '@nestjs/event-emitter' ;
3
- import * as mongoose from 'mongoose' ;
3
+ import { Types } from 'mongoose' ;
4
4
import { FilterQuery , UpdateQuery } from 'mongoose' ;
5
5
import { PageQueryDto } from '../../dto/page-query.dto' ;
6
6
import { CreateOrganizationDto } from './dto/create-organization.dto' ;
@@ -26,7 +26,7 @@ export class OrganizationsService {
26
26
}
27
27
28
28
async update (
29
- id : mongoose . Types . ObjectId ,
29
+ id : Types . ObjectId ,
30
30
query : UpdateQuery < OrganizationDocument > ,
31
31
) : Promise < OrganizationDocument | null > {
32
32
const org = await this . organizationRepository . findOneByIdAndUpdate ( id , { $set : query } ) ;
@@ -38,10 +38,7 @@ export class OrganizationsService {
38
38
return org ;
39
39
}
40
40
41
- async updateSettings (
42
- id : mongoose . Types . ObjectId ,
43
- settings : FilterQuery < OrgSettingsDocument | null > ,
44
- ) {
41
+ async updateSettings ( id : Types . ObjectId , settings : FilterQuery < OrgSettingsDocument | null > ) {
45
42
const org = await this . organizationRepository . findOneByIdAndUpdate ( id , {
46
43
$set : { settings : settings } ,
47
44
} ) ;
@@ -53,7 +50,7 @@ export class OrganizationsService {
53
50
return org ;
54
51
}
55
52
56
- async delete ( id : mongoose . Types . ObjectId ) : Promise < OrganizationDocument | null > {
53
+ async delete ( id : Types . ObjectId ) : Promise < OrganizationDocument | null > {
57
54
const org = await this . organizationRepository . deleteOneById ( id ) ;
58
55
59
56
if ( ! org ) return ;
@@ -65,19 +62,19 @@ export class OrganizationsService {
65
62
return org ;
66
63
}
67
64
68
- async listAllForUser ( id : mongoose . Types . ObjectId ) : Promise < OrganizationDocument [ ] > {
65
+ async listAllForUser ( id : Types . ObjectId ) : Promise < OrganizationDocument [ ] > {
69
66
return this . organizationRepository . find ( { 'acls.user' : id } ) ;
70
67
}
71
68
72
- async paginateAllForUser ( id : mongoose . Types . ObjectId , pageQueryDto : PageQueryDto ) {
69
+ async paginateAllForUser ( id : Types . ObjectId , pageQueryDto : PageQueryDto ) {
73
70
return this . organizationRepository . paginate ( { 'acls.user' : id } , pageQueryDto ) ;
74
71
}
75
72
76
- async findById ( id : mongoose . Types . ObjectId ) : Promise < OrganizationDocument > {
73
+ async findById ( id : Types . ObjectId ) : Promise < OrganizationDocument > {
77
74
return this . organizationRepository . findById ( id ) ;
78
75
}
79
76
80
- async exist ( id : mongoose . Types . ObjectId ) : Promise < boolean > {
77
+ async exist ( id : Types . ObjectId ) : Promise < boolean > {
81
78
return this . organizationRepository . exist ( { _id : id } ) ;
82
79
}
83
80
0 commit comments