public async queryEntitiesWithPartitionAndRowKey()

in src/table/handlers/TableHandler.ts [725:819]


  public async queryEntitiesWithPartitionAndRowKey(
    _table: string,
    partitionKey: string | undefined,
    rowKey: string | undefined,
    options: Models.TableQueryEntitiesWithPartitionAndRowKeyOptionalParams,
    context: Context
  ): Promise<Models.TableQueryEntitiesWithPartitionAndRowKeyResponse> {
    const tableContext = new TableStorageContext(context);
    const account = this.getAndCheckAccountName(tableContext);
    const table = _table ? _table : this.getAndCheckTableName(tableContext);

    [partitionKey, rowKey] = TableHandler.getAndCheckKeys(
      partitionKey,
      rowKey,
      tableContext,
      context
    );

    const accept = this.getAndCheckPayloadFormat(tableContext);

    const entity =
      await this.metadataStore.queryTableEntitiesWithPartitionAndRowKey(
        context,
        table,
        account,
        partitionKey,
        rowKey,
        tableContext.batchId
      );

    if (entity === undefined || entity === null) {
      throw StorageErrorFactory.getEntityNotFound(context);
    }

    const response: Models.TableQueryEntitiesWithPartitionAndRowKeyResponse = {
      statusCode: 200,
      date: tableContext.startTime,
      clientRequestId: options.requestId,
      requestId: context.contextID,
      eTag: entity.eTag,
      version: TABLE_API_VERSION
    };

    const body = {} as any;
    const annotation = getEntityOdataAnnotationsForResponse(
      account,
      table,
      this.getOdataAnnotationUrlPrefix(tableContext, account),
      partitionKey,
      rowKey,
      accept
    );

    if (accept === MINIMAL_METADATA_ACCEPT) {
      body["odata.metadata"] = annotation.odatametadata;
      body["odata.etag"] = entity.eTag;
    }

    if (accept === FULL_METADATA_ACCEPT) {
      body["odata.metadata"] = annotation.odatametadata;
      body["odata.type"] = annotation.odatatype;
      body["odata.id"] = annotation.odataid;
      body["odata.etag"] = entity.eTag;
      body["odata.editLink"] = annotation.odataeditLink;
    }

    let selectSet: Set<string> | undefined;
    const selectArray = options.queryOptions?.select
      ?.split(",")
      .filter((item) => {
        return typeof item === "string" && item.length > 0;
      })
      .map((item) => item.trim());
    if (selectArray && selectArray.length > 0) {
      selectSet = new Set(selectArray);
    }

    const normalizedEntity = new NormalizedEntity(entity);
    const rawResponse = normalizedEntity.toResponseString(
      accept,
      body,
      selectSet
    );
    response.body = new BufferStream(Buffer.from(rawResponse));

    this.logger.debug(
      `TableHandler:queryEntities() Raw response string is ${JSON.stringify(
        rawResponse
      )}`,
      context.contextID
    );

    this.updateResponseAccept(tableContext, accept);
    return response;
  }