Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Query parameters docs #16

Merged
merged 2 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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
Loading