Ask AI
Skip to main content

Fetch a list of data records v4

Function: Fetch a list of data records v4

This action allows you to retrieve a list of data entries from your application's built-in database. You can precisely define which data to fetch by applying various filters, specifying which fields to include, grouping or aggregating data, connecting to other data sources (joins), and controlling how the results are sorted and paginated. This is ideal for displaying dynamic lists, reports, or filtered views of your data.

Input

  • Data schema: The specific type of data (e.g., "Products", "Orders", "Users") you want to retrieve records for. This is a required selection.
  • Attributes: (Optional) Define specific fields from your chosen data schema to include in the results. You can also choose to group results by an attribute, get only distinct values, or apply aggregation functions (like sum, count, average) to numerical fields.
    • Attribute: The specific field from your data schema to include.
    • Group by: (True/False) If set to 'True', the results will be grouped based on the unique values of this attribute.
    • Distinct: (True/False) If set to 'True', only unique values for this attribute will be returned.
    • Aggregation: (Dropdown) If you want to perform a calculation on a numerical attribute, select an aggregation type (e.g., "Sum", "Count", "Average", "Min", "Max").
    • Attribute Filters (AND): (Optional) Apply additional filters specifically to this attribute. All conditions must be true.
      • Filter Attribute: The field to apply the filter to (usually the same as the main attribute).
      • Filter Operator: How to compare the attribute value (e.g., "Equals", "Not Equals", "Greater Than", "Contains", "Is Empty").
      • Filter Value: The value to compare against.
  • Filters (And): (Optional) A list of conditions that all must be true for a data record to be included in the results.
    • Filter Attribute: The field to apply the filter to.
    • Filter Operator: How to compare the attribute value (e.g., "Equals", "Not Equals", "Greater Than", "Contains", "Is Empty").
    • Filter Value: The value to compare against.
  • Filters (Or): (Optional) A list of conditions where at least one must be true for a data record to be included in the results.
    • Filter Attribute: The field to apply the filter to.
    • Filter Operator: How to compare the attribute value (e.g., "Equals", "Not Equals", "Greater Than", "Contains", "Is Empty").
    • Filter Value: The value to compare against.
  • Joins: (Optional) Connect data from another data schema based on matching fields. This allows you to retrieve related information alongside your main data.
    • Join Data Schema: The data schema you want to connect with (e.g., "Customers" if your main schema is "Orders").
    • Local Field: The field in your current data schema that links to the joined data schema.
    • Target Field: The field in the joined data schema that links back to your current data schema.
    • Join Filters (AND): (Optional) Filters applied specifically to the joined data. All conditions must be true.
    • Join Filters (OR): (Optional) Filters applied specifically to the joined data. At least one condition must be true.
    • Nested Joins: You can add more joins to the joined data schema, creating multi-level connections.
  • Sort by: (Optional) Define how the retrieved list of data should be ordered. You can add multiple sorting rules.
    • Attribute: The field by which to sort the results.
    • Order: Choose "Ascending" (A-Z, 0-9) or "Descending" (Z-A, 9-0).
  • Page: The specific page number of results you want to fetch. The first page is 0. This is a required number, defaulting to 0.
  • Amount per page: The maximum number of data records to return on a single page. This is a required number, defaulting to 10.

Output

  • Found data page: A variable that will store the list of data records retrieved from the database. This variable will contain a "page" of data, meaning it includes the records for the specified page number and amount per page. The default name for this variable is FOUND_DATA.

Execution Flow

Real-Life Examples

Example 1: Displaying the first page of active products

Imagine you have an e-commerce application and want to show the first 10 active products on your homepage.

  • Inputs:
    • Data schema: Products
    • Filters (And):
      • Filter Attribute: Status
      • Filter Operator: Equals
      • Filter Value: Active
    • Page: 0
    • Amount per page: 10
  • Result: The FOUND_DATA variable will contain a list of the first 10 products that have a Status of Active.

Example 2: Listing recent orders for a specific customer, sorted by date

You want to show a customer their last 5 orders, with the most recent ones appearing first.

  • Inputs:
    • Data schema: Orders
    • Filters (And):
      • Filter Attribute: CustomerID
      • Filter Operator: Equals
      • Filter Value: [Current Customer ID] (a variable holding the logged-in customer's ID)
    • Sort by:
      • Attribute: OrderDate
      • Order: Descending
    • Page: 0
    • Amount per page: 5
  • Result: The FOUND_DATA variable will hold a list of the 5 most recent orders placed by the specified customer.

Example 3: Generating a report of product categories with their total sales

You need to see a summary of your product categories and the total revenue generated by each.

  • Inputs:
    • Data schema: Products
    • Attributes:
      • Attribute: Category
      • Group by: True
      • Distinct: False
      • Aggregation: None
      • (Add another attribute for sales)
      • Attribute: Price
      • Group by: False
      • Distinct: False
      • Aggregation: Sum
    • Joins: (Assuming Products has a CategoryID that links to a Categories schema)
      • Join Data Schema: Categories
      • Local Field: CategoryID
      • Target Field: ID
    • Page: 0
    • Amount per page: 9999 (to get all results on one page for a report)
  • Result: The FOUND_DATA variable will contain a list where each item represents a unique product category, along with the sum of prices (total sales) for products within that category.