From d0868a0836ad08db82796606403974f6042dd262 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 9 Jul 2024 12:48:02 -0400 Subject: [PATCH] feat: add odata filter support for table-storage Fixes #1054 --- README.md | 4 ++-- lib/table-storage/azure-table.repository.ts | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 225bbd89..7eb5f06d 100644 --- a/README.md +++ b/README.md @@ -408,10 +408,10 @@ The `AzureTableStorageRepository` provides a list of public methods for managing } ``` -`findAll(): Promise`: finds all entities (NOTE: odata filters are not supported yet). +`findAll(options: { queryOptions?: TableEntityQueryOptions }): Promise`: finds all entities. ```typescript - async findAll(): Promise { + async findAll(options: { queryOptions?: TableEntityQueryOptions }): Promise { return await this.eventRepository.findAll(); } ``` diff --git a/lib/table-storage/azure-table.repository.ts b/lib/table-storage/azure-table.repository.ts index 80ddbb3a..eba6109e 100644 --- a/lib/table-storage/azure-table.repository.ts +++ b/lib/table-storage/azure-table.repository.ts @@ -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'; @@ -60,13 +60,12 @@ export class AzureTableStorageRepository { } } - async findAll(): Promise { + async findAll(options: { queryOptions?: TableEntityQueryOptions } = {}): Promise { 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 = [];