async findAll()

in services/application/apps/product/src/products/products.service.ts [51:75]


  async findAll(tenantId: string) {
    console.log('Getting All Products for Tenant:', tenantId);
    try {
      const client = await this.fetchClient(tenantId);
      const cmd = new QueryCommand({
        TableName: this.tableName,
        KeyConditionExpression: 'tenant_id=:t_id',
        ExpressionAttributeValues: {
          ':t_id': tenantId,
        },
      });

      const response = await client.send(cmd);
      return JSON.stringify(response.Items);
    } catch (error) {
      console.error(error);
      throw new HttpException(
        {
          status: HttpStatus.INTERNAL_SERVER_ERROR,
          error: error,
        },
        HttpStatus.INTERNAL_SERVER_ERROR,
      );
    }
  }