Skip to content

Commit

Permalink
feat: add odata filter support for table-storage
Browse files Browse the repository at this point in the history
Fixes #1054
  • Loading branch information
nlaurie authored and manekinekko committed Sep 5, 2024
1 parent d95a565 commit d0868a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,10 @@ The `AzureTableStorageRepository` provides a list of public methods for managing
}
```

`findAll(): Promise<T[]>`: finds all entities (NOTE: odata filters are not supported yet).
`findAll(options: { queryOptions?: TableEntityQueryOptions }): Promise<T[]>`: finds all entities.

```typescript
async findAll(): Promise<Event[]> {
async findAll(options: { queryOptions?: TableEntityQueryOptions }): Promise<Event[]> {
return await this.eventRepository.findAll();
}
```
Expand Down
7 changes: 3 additions & 4 deletions lib/table-storage/azure-table.repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeleteTableEntityResponse, TableEntity } from '@azure/data-tables';
import { DeleteTableEntityResponse, TableEntity, TableEntityQueryOptions } from '@azure/data-tables';
import { Inject, Injectable, Logger } from '@nestjs/common';
import { AZURE_TABLE_STORAGE_FEATURE_OPTIONS, AZURE_TABLE_STORAGE_NAME } from './azure-table.constant';
import { AzureTableStorageFeatureOptions } from './azure-table.interface';
Expand Down Expand Up @@ -60,13 +60,12 @@ export class AzureTableStorageRepository<T> {
}
}

async findAll(): Promise<T[]> {
async findAll(options: { queryOptions?: TableEntityQueryOptions } = {}): Promise<T[]> {
logger.debug(`Looking for entities in table: ${this.tableName}`);

try {
const records = this.tableClientInstance.listEntities({
// TODO: odata filters on findAll is not supported yet (see: https://github.com/Azure/azure-sdk-for-js/issues/19494)
// queryOptions: { filter: odata`${filter}`, select: [] },
queryOptions: options.queryOptions,
});

const entities = [];
Expand Down

0 comments on commit d0868a0

Please sign in to comment.