diff --git a/README.md b/README.md index 71947f4..2e3b75f 100644 --- a/README.md +++ b/README.md @@ -174,6 +174,21 @@ 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();