GithubHelp home page GithubHelp logo

Comments (6)

nlaurie avatar nlaurie commented on September 27, 2024 1

Here is a patch if they don't accept the PR anytime soon , just use findAll2

import { TableEntityQueryOptions } from '@azure/data-tables';
import { AzureTableStorageRepository } from '@nestjs/azure-database';
import { Logger } from '@nestjs/common';

export * from '@nestjs/azure-database';

const logger = new Logger('AzureStorageRepository');

// Remove the verbose output
// eslint-disable-next-line @typescript-eslint/no-empty-function
console.table = function () {};

declare module '@nestjs/azure-database' {
  interface AzureTableStorageRepository<T> {
    findAll2(options?: { queryOptions?: TableEntityQueryOptions }): Promise<T[]>;
  }
}

AzureTableStorageRepository.prototype.findAll2 = async function <T>(
  options: { queryOptions?: TableEntityQueryOptions } = {}
): Promise<T[]> {
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  // @ts-ignore
  logger.debug(`Looking for entities in table: ${this.tableName}`);

  try {
    const records = this.tableClientInstance.listEntities({
      queryOptions: options.queryOptions,
    });

    const entities = [];
    for await (const entity of records) {
      entities.push(entity);
    }

    logger.debug(`Entities fetched successfully`);
    return entities as T[];
  } catch (error) {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return this.handleRestErrors(error);
  }
};

from azure-database.

nlaurie avatar nlaurie commented on September 27, 2024

I just ran into this same issue , absolutely need to filter by partitionKey at a minimum

from azure-database.

nlaurie avatar nlaurie commented on September 27, 2024

I added a PR to fix this , I been using filtering directly to azure for some time now

#1055

from azure-database.

lufinima avatar lufinima commented on September 27, 2024

I added a PR to fix this , I been using filtering directly to azure for some time now

#1055

For backwards compatibility I would make the options parameter optional if and actual options is passed so then it would use it, if not would works as is right now.
My take on it was like this as I don't need other thing than the filter to be different:

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

    try {
      let options: ListTableEntitiesOptions = {};
      if (typeof filter !== 'undefined') {
        options = {
          queryOptions: { filter: `${filter}`, select: [] },
        };
      }

      const records = this.tableClientInstance.listEntities(options);
      ...

from azure-database.

nlaurie avatar nlaurie commented on September 27, 2024

From what I saw in the code, there was no filter?:string param in the latest code.

async findAll(): Promise<T[]> {

The way I did it was backwards compatible and provides the full support to the listEntities() including the select which is important when needing to delete lots of large rows.

async findAll(options: { queryOptions?: TableEntityQueryOptions } = {}): Promise<T[]>

I use "select" to query and return just the rowKey using the select:['RowKey']. and iterate the results to do targeted deletes. Important when storing large blob data.

I can change it to the question mark notation as opposed to the default , if thats what you want. would be equally backward compatible. I like to use a generic options param because it gives you increased flexibility to adding additional backward compatible features in the future.

from azure-database.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.