use skip and take instead of limit, offset
This commit is contained in:
@ -31,7 +31,7 @@ export const userRepository = entityManager.getRepository(User).extend({
|
||||
.where({
|
||||
profile: { username: In(TOP_USERS) },
|
||||
})
|
||||
.limit(MAX_RECORDS_LIMIT)
|
||||
.take(MAX_RECORDS_LIMIT)
|
||||
.getMany()
|
||||
},
|
||||
})
|
||||
|
||||
@ -690,7 +690,7 @@ export const searchResolver = authorized<
|
||||
pageInfo: {
|
||||
hasPreviousPage: false,
|
||||
startCursor,
|
||||
hasNextPage: hasNextPage,
|
||||
hasNextPage,
|
||||
endCursor,
|
||||
totalCount: count,
|
||||
},
|
||||
|
||||
@ -289,15 +289,14 @@ export const searchLibraryItems = async (
|
||||
.leftJoinAndSelect('library_item.highlights', 'highlights')
|
||||
.leftJoinAndSelect('highlights.user', 'user')
|
||||
.leftJoinAndSelect('user.profile', 'profile')
|
||||
.where('library_item.user_id = :userId', { userId })
|
||||
|
||||
// build the where clause
|
||||
buildWhereClause(queryBuilder, args)
|
||||
|
||||
const libraryItems = await queryBuilder
|
||||
.addOrderBy(`library_item.${sortField}`, sortOrder)
|
||||
.offset(from)
|
||||
.limit(size)
|
||||
.skip(from)
|
||||
.take(size)
|
||||
.getMany()
|
||||
|
||||
const count = await queryBuilder.getCount()
|
||||
@ -432,7 +431,7 @@ export const findLibraryItemsByPrefix = async (
|
||||
.orWhere('library_item.site_name ILIKE :prefix', {
|
||||
prefix: prefixWildcard,
|
||||
})
|
||||
.orderBy('library_item.saved_at', 'DESC')
|
||||
.orderBy('library_item.savedAt', 'DESC')
|
||||
.limit(limit)
|
||||
.getMany()
|
||||
)
|
||||
|
||||
@ -67,12 +67,11 @@ export interface DateFilter {
|
||||
}
|
||||
|
||||
export enum SortBy {
|
||||
SAVED = 'saved_at',
|
||||
UPDATED = 'updated_at',
|
||||
PUBLISHED = 'published_at',
|
||||
READ = 'read_at',
|
||||
LISTENED = 'listened_at',
|
||||
WORDS_COUNT = 'word_count',
|
||||
SAVED = 'savedAt',
|
||||
UPDATED = 'updatedAt',
|
||||
PUBLISHED = 'publishedAt',
|
||||
READ = 'readAt',
|
||||
WORDS_COUNT = 'wordCount',
|
||||
}
|
||||
|
||||
export enum SortOrder {
|
||||
|
||||
Reference in New Issue
Block a user