async findAll()

in services/application/apps/order/src/orders/orders.service.ts [50:81]


  async findAll(tenantId: string) {
    console.log('Get all orders:', tenantId, 'Table Name:', this.tableName);
    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);
      console.log('Response:', response);
      const items = response.Items;
      const orders = items.map((i) => {
        return {
          ...i,
          products: JSON.parse(i.products),
        };
      });
      return JSON.stringify(orders);
    } catch (error) {
      console.error(error);
      throw new HttpException(
        {
          status: HttpStatus.INTERNAL_SERVER_ERROR,
          error: error,
        },
        HttpStatus.INTERNAL_SERVER_ERROR,
      );
    }
  }