Skip to content

Commit 8d491ed

Browse files
type ids as objectId
1 parent a7665fc commit 8d491ed

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

service/src/tickets/thread/thread.service.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,29 @@ export class ThreadService extends AbstractServiceSchema {
3434
): Promise<[Query<Array<T>, T, any, T>[], number]> {
3535
if (!filter.ticketId) throw new ConflictException('Search must be contain filter by ticketId')
3636
//TODO: check acl
37-
return await super.findAndCount({
38-
...filter,
39-
ticketId: new Types.ObjectId(filter.ticketId),
40-
}, projection, options)
37+
return await super.findAndCount(
38+
{
39+
...filter,
40+
ticketId: new Types.ObjectId(filter.ticketId),
41+
},
42+
projection,
43+
options,
44+
)
4145
}
4246

4347
public async create<T extends AbstractSchema | Document>(data?: ThreadCreateDto, options?: SaveOptions): Promise<Document<T, any, T>> {
4448
const count = await this.ticketService.count({ _id: data.ticketId })
4549
if (!count) throw new ConflictException(this.i18n.t(`thread.service.create.ticketNotFound`))
50+
data.ticketId = new Types.ObjectId(data.ticketId)
51+
data.fragments.map((fragment) => {
52+
fragment.id = new Types.ObjectId()
53+
return fragment
54+
})
55+
4656
return await super.create(data, options)
4757
}
4858

49-
public async delete<T extends AbstractSchema | Document>(
50-
_id: Types.ObjectId | any,
51-
options?: QueryOptions<T> | null | undefined,
52-
): Promise<Query<T, T, any, T>> {
59+
public async delete<T extends AbstractSchema | Document>(_id: Types.ObjectId | any, options?: QueryOptions<T> | null | undefined): Promise<Query<T, T, any, T>> {
5360
//TODO: check acl
5461
return await super.delete(_id, options)
5562
}

0 commit comments

Comments
 (0)