@@ -12,7 +12,7 @@ import {
1212 UserWithoutSensetives
1313} from "../database/entities/User" ;
1414import { IUsersService } from "./interfaces/UsersServiceInterface" ;
15- import { INotesService } from "./interfaces/NotesServiceInterface" ;
15+ import { INotesService , NotesSearchOptions } from "./interfaces/NotesServiceInterface" ;
1616import { NOTE_EXCEPTIONS } from "../exceptions/NoteExceptions" ;
1717import { Repository } from "typeorm" ;
1818import { transformNoteCollaborators } from "../utils/common/TransformNoteCollaborators" ;
@@ -161,14 +161,10 @@ export class NotesService implements INotesService {
161161 return transformNoteCollaborators ( updatedNote ) as unknown as Note ;
162162 }
163163
164- // TODO: pack all arguments after authorLogin in one object
165164 @withExceptionCatch
166165 public async getMyNotes (
167166 authorLogin : string ,
168- tags : string [ ] ,
169- limit : number ,
170- skip : number ,
171- sort : "ASC" | "DESC"
167+ options : NotesSearchOptions
172168 ) {
173169 const query = this . noteRepository
174170 . createQueryBuilder ( "note" )
@@ -180,10 +176,11 @@ export class NotesService implements INotesService {
180176 "note.updatedAt"
181177 ] )
182178 . where ( "note.author = :login" , { login : authorLogin } )
183- . limit ( limit )
184- . skip ( skip )
185- . orderBy ( "note.updatedAt" , sort ) ;
179+ . limit ( options ?. limit )
180+ . skip ( options ?. skip )
181+ . orderBy ( "note.updatedAt" , options ?. sort ) ;
186182
183+ const tags = options ?. tags
187184 if ( tags && tags . length ) {
188185 query . where ( "note.tags && :tags" , { tags} ) ;
189186 }
@@ -192,14 +189,10 @@ export class NotesService implements INotesService {
192189 return foundNotes as unknown as NotePreview [ ] ;
193190 }
194191
195- // TODO: pack all arguments after authorLogin in one object
196192 @withExceptionCatch
197193 public async getCollaboratedNotes (
198194 login : string ,
199- tags : string [ ] ,
200- limit : number ,
201- skip : number ,
202- sort : "ASC" | "DESC"
195+ options : NotesSearchOptions
203196 ) {
204197 const query = this . noteRepository
205198 . createQueryBuilder ( "note" )
@@ -216,10 +209,11 @@ export class NotesService implements INotesService {
216209 "note.tags" ,
217210 "note.updatedAt"
218211 ] )
219- . limit ( limit )
220- . skip ( skip )
221- . orderBy ( "note.updatedAt" , sort ) ;
222-
212+ . limit ( options ?. limit )
213+ . skip ( options ?. skip )
214+ . orderBy ( "note.updatedAt" , options ?. sort ) ;
215+
216+ const tags = options ?. tags
223217 if ( tags && tags . length ) {
224218 query . where ( "note.tags && :tags" , { tags} ) ;
225219 }
0 commit comments