Skip to content

Commit

Permalink
Add Query parameters docs
Browse files Browse the repository at this point in the history
  • Loading branch information
joseffffff committed Jun 29, 2024
1 parent 185512e commit 261c7b8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/GoogleSpreadsheetsOrm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export class GoogleSpreadsheetsOrm<T extends BaseModel> {
* 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<T> = {}): Promise<T[]> {
const { data, headers } = await this.findSheetData();
Expand Down

0 comments on commit 261c7b8

Please sign in to comment.