From 261c7b8bfb0a91d2e51995cba6600efd29361dd2 Mon Sep 17 00:00:00 2001 From: joseffffff Date: Sat, 29 Jun 2024 18:09:22 +0200 Subject: [PATCH 1/2] Add Query parameters docs --- README.md | 20 ++++++++++++++++++++ src/GoogleSpreadsheetsOrm.ts | 2 ++ 2 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 71947f4..19c88a6 100644 --- a/README.md +++ b/README.md @@ -174,6 +174,26 @@ const myEntities = await orm.all(); - **Returns**: A Promise that resolves to an array of entities of type `T`, representing all rows retrieved from the sheet. +#### Filtering + +`all` method also accepts an object to filter data from spreadsheet, example: + +```typescript +orm.all({ + filter: { + // Filter by specific value + id: '1111-2222-3333-4444', + // Or... Filter by values contained in an array + id: [ + '1111-1111-1111-1111', + '2222-2222-2222-2222', + '3333-3333-3333-3333', + '4444-4444-4444-4444', + ], + }, +}); +``` + ### `create(entity: T)` Creates a new row in the specified sheet with the provided entity data. diff --git a/src/GoogleSpreadsheetsOrm.ts b/src/GoogleSpreadsheetsOrm.ts index 15297c5..468fadd 100644 --- a/src/GoogleSpreadsheetsOrm.ts +++ b/src/GoogleSpreadsheetsOrm.ts @@ -52,6 +52,8 @@ export class GoogleSpreadsheetsOrm { * It then parses the retrieved data and serializes it into entities according to the field types defined in the Castings configuration. * * @returns A Promise that resolves to an array of entities of type T, representing all rows retrieved from the sheet. + * + * @param options - Object to filter data from spreadsheet */ public async all(options: Query = {}): Promise { const { data, headers } = await this.findSheetData(); From b0ab16ce2a47c707537dc66747d5269c60e21a69 Mon Sep 17 00:00:00 2001 From: joseffffff Date: Sat, 29 Jun 2024 18:11:08 +0200 Subject: [PATCH 2/2] prettier:fix --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 19c88a6..2e3b75f 100644 --- a/README.md +++ b/README.md @@ -184,12 +184,7 @@ orm.all({ // Filter by specific value id: '1111-2222-3333-4444', // Or... Filter by values contained in an array - id: [ - '1111-1111-1111-1111', - '2222-2222-2222-2222', - '3333-3333-3333-3333', - '4444-4444-4444-4444', - ], + id: ['1111-1111-1111-1111', '2222-2222-2222-2222', '3333-3333-3333-3333', '4444-4444-4444-4444'], }, }); ```