diff --git a/plugins/notifications-backend/src/database/DatabaseNotificationsStore.test.ts b/plugins/notifications-backend/src/database/DatabaseNotificationsStore.test.ts index d8ae3faf57..429aea4f3d 100644 --- a/plugins/notifications-backend/src/database/DatabaseNotificationsStore.test.ts +++ b/plugins/notifications-backend/src/database/DatabaseNotificationsStore.test.ts @@ -469,6 +469,11 @@ describe.each(databases.eachSupportedId())( id3, ]); }); + + it('should return empty array when limit is 0', async () => { + const result = await storage.getNotifications({ user, limit: 0 }); + expect(result).toEqual([]); + }); }); describe('getNotifications sorting', () => { diff --git a/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts b/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts index 5bed0c7674..6ebd64f4f4 100644 --- a/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts +++ b/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts @@ -289,11 +289,11 @@ export class DatabaseNotificationsStore implements NotificationsStore { } } - if (options.limit) { + if (options.limit !== undefined) { query.limit(options.limit); } - if (options.offset) { + if (options.offset !== undefined) { query.offset(options.offset); }