feat(F-048): completed feature
This commit is contained in:
@@ -76,11 +76,16 @@ class FakeProductRepository implements ProductRepository {
|
||||
// noop for tests
|
||||
}
|
||||
|
||||
async listAll(options?: { limit?: number; offset?: number; q?: string }): Promise<{ items: Product[]; total: number }> {
|
||||
async listAll(options?: {
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
q?: string;
|
||||
}): Promise<{ items: Product[]; total: number }> {
|
||||
const limit = options?.limit ?? 20;
|
||||
const offset = options?.offset ?? 0;
|
||||
let items = [...this.products];
|
||||
if (options?.q) items = items.filter((p) => p.name.toLowerCase().includes(options.q!.toLowerCase()));
|
||||
if (options?.q)
|
||||
items = items.filter((p) => p.name.toLowerCase().includes(options.q!.toLowerCase()));
|
||||
return { items: items.slice(offset, offset + limit), total: items.length };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user