aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/user/sql
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/user/sql')
-rw-r--r--server/models/user/sql/user-notitication-list-query-builder.ts25
1 files changed, 10 insertions, 15 deletions
diff --git a/server/models/user/sql/user-notitication-list-query-builder.ts b/server/models/user/sql/user-notitication-list-query-builder.ts
index 9eae4fc22..6a6a71e3a 100644
--- a/server/models/user/sql/user-notitication-list-query-builder.ts
+++ b/server/models/user/sql/user-notitication-list-query-builder.ts
@@ -1,5 +1,5 @@
1import { QueryTypes, Sequelize } from 'sequelize' 1import { Sequelize } from 'sequelize'
2import { ModelBuilder } from '@server/models/shared' 2import { AbstractRunQuery, ModelBuilder } from '@server/models/shared'
3import { getSort } from '@server/models/utils' 3import { getSort } from '@server/models/utils'
4import { UserNotificationModelForApi } from '@server/types/models' 4import { UserNotificationModelForApi } from '@server/types/models'
5import { ActorImageType } from '@shared/models' 5import { ActorImageType } from '@shared/models'
@@ -10,28 +10,23 @@ export interface ListNotificationsOptions {
10 sort: string 10 sort: string
11 offset: number 11 offset: number
12 limit: number 12 limit: number
13 sequelize: Sequelize
14} 13}
15 14
16export class UserNotificationListQueryBuilder { 15export class UserNotificationListQueryBuilder extends AbstractRunQuery {
17 private innerQuery: string 16 private innerQuery: string
18 private replacements: any = {}
19 private query: string
20
21 constructor (private readonly options: ListNotificationsOptions) {
22 17
18 constructor (
19 protected readonly sequelize: Sequelize,
20 private readonly options: ListNotificationsOptions
21 ) {
22 super(sequelize)
23 } 23 }
24 24
25 async listNotifications () { 25 async listNotifications () {
26 this.buildQuery() 26 this.buildQuery()
27 27
28 const results = await this.options.sequelize.query(this.query, { 28 const results = await this.runQuery({ nest: true })
29 replacements: this.replacements, 29 const modelBuilder = new ModelBuilder<UserNotificationModelForApi>(this.sequelize)
30 type: QueryTypes.SELECT,
31 nest: true
32 })
33
34 const modelBuilder = new ModelBuilder<UserNotificationModelForApi>(this.options.sequelize)
35 30
36 return modelBuilder.createModels(results, 'UserNotification') 31 return modelBuilder.createModels(results, 'UserNotification')
37 } 32 }