Query All Records
Last updated
Last updated
Query All Records is used to retrieve records from a database table. You can set various filters and other options to determine exactly which records to retrieve.
Query All Records offers three panels for various settings: filter, output, and external.
The Filter tab is used to determine what records will be returned from the database.
This is the section you'll use to determine what records to return. If you leave it blank, all records will be returned.
Click the icon to edit the custom query, and choose Add A Conditional from the panel that opens.
Joins are an advanced concept that allows you to find matching records between tables. For example, let's say you have a table of orders
, and each of those orders contain products of a specific color. We want to determine how many orders each customer made with products matching their favorite color.
You have two tables with the following data:
Customers
: Names and their favorite color
Orders
: Color and price of items sold
When you join these tables using the color as the connection point, you can see which customers bought items matching their favorite color.
There are different ways to combine these lists:
Inner join: Only shows matches (like customers who bought their favorite color)
Left join: Shows all customers, even if they haven't bought anything
Right join: Shows all orders, even if no customer likes that color
So if Sarah likes blue and there's a blue sweater order, an inner join would connect them. But if Tom likes green and he hasn't placed any orders with green items, he'd only appear in a left join.
Joins are useful because they allow you to consolidate all of this into a single database operation, instead of querying multiple tables and manually matching the data in several additional steps.
Addons are a way for you to enrich a query's result with related data from other tables, such as getting product information and orders together. This is usually facilitated by using table reference fields.
You'll see this attached to the base level of the response, table reference fields, and list fields. It's important to choose the correct Addon button based on the data you're trying to enhance.
In this example, we have an Order table that just contains product IDs, and we want to see actual product information instead.
You can also select from already created addons from here.
This name is just for you, so you can find the addon you're creating later.
Our parent object in this case is each product ID. The parent object is just whatever you are adding on to — think back to a few steps ago when we clicked the Addon button inside of product_id.
We want each product to be nested under a key called product_info, so that's what we'll put here.
Click to apply a sort to the returned records. You can apply multiple sorts for further customization.
Check to enable pagination for this query. You can specify which page to return, and how many records should be returned for each page.
Check if you want to include paging metadata, as shown below, in your return. You can also opt to include the total item count, which is the total number of records in the table.
You can also click to change the response if you only want certain fields returned.
Note that customizing to reduce the fields returned will not have an impact on query speed, but may help with other performance issues in your function stacks. It is always good practice to only return the fields necessary.
Change the variable name that this function will output to.
If you're using conditional steps, you can use the same variable name in multiple steps to make satisfying the conditional or outputting data in the response easier.
For example, if we are sending a specific response based on if a variable is true or false, we can set both of those outputs to the same variable, making building our response easier.
Click to edit the fields returned in the query.
Each conditional has four different components.
Conditional Type
The conditional type determines how this condition is weighted in the final return. You can choose between AND and OR. AND conditionals require the present conditional and any others before it to be satisfied, such as "where the date is before today AND the user is an admin". OR conditionals do not require any other conditionals to be satisfied, such as "if the user is an admin OR if the user is a manager".
Left Value
This is the first value you're using in the conditional. In a database query, this is usually going to be a column that you want to check against.
Operators
Please note that operators may differ based on where you are building the expression. Database queries will have different operators available than regular conditional statements.
Equals (==) - an exact match
Not Equals (!=) - does not equal
Equals with type matching (===) - an exact value match and an exact type match
Ex. Variable var_1 has a value of 123, with a type of text. You set up a conditional statement to check if var_1 === 123, but your value in the conditional statement is of type integer. This would return false, because the types do not match.
Not equals with type matching (!==) - does not equal value or type, similar to ===
Greater than (>) - the value on the left is greater than the value on the right
Greater than or equals (≥) - the value on the left is greater than or equals to the value on the right.
Less than (<) - the value on the left is less than the value on the right.
Less than or equals (≤) - the value on the left is less than or equals to the value on the right.
LIKE - Used for comparing text. Like is case-insensitive and compares if a text string is like another text string. It can be thought of as equals for text but upper case and lower case does not matter.
NOT LIKE - Used for comparing text. Not Like is case-insensitive and compares if a text string is not like another. It is like not equals for text but upper case and lower case does not matter.
INCLUDES - Used for comparing text. Includes is a flexible operator and is case-insensitive. It is able to determine if there is a partial match in a text string.
DOES NOT INCLUDE - Used for comparing text. Does not include determines if a text string is not included in another text string.
IN - If a single value is found in an array (list). Start with the single value on the left side and the right side should contain the array.
NOT IN - If a single value is not found in an array (list). The single value should be on the left side and the array on the right side.
REGEX MATCHES - Regular Expression used for finding patterns in text.
REGEX DOES NOT MATCH - Regular Expression used for finding a pattern that does not match in text.
OVERLAPS - Used for comparing two arrays. Overlaps determines if any values in one array are present in the second array.
DOES NOT OVERLAP - Used for comparing two arrays. Does not overlaps determines if no values in the first array are present in the second array.
CONTAINS - Contains is an advanced filter used for JSON and arrays. It looks for an exact schema match.
DOES NOT CONTAIN - Does not contain is the opposite of contains. It determines if there is not an exact schema match.
The right value is whatever you are checking against the left value. This could be a hardcoded value, a variable, or even a database field from the same record.
exists - Returns a true or false based on if records were returned count - Returns the number of records found single - Returns the first record found list - Returns a list of records stream - When used with a For Each Loop, maintains memory efficiency when iterating through large lists of records aggregate - Perform special aggregation functions on the returned records
exists - Returns a true or false based on if records were returned count - Returns the number of records found single - Returns the first record found list - Returns a list of records stream - When used with a For Each Loop, maintains memory efficiency when iterating through large lists of records aggregate - Perform special aggregation functions on the returned records