Query All Records
Simple Query
Get all records from a tableParameter | Purpose | Example |
---|---|---|
table | The name of the table to query | user |
as | The variable to store the result | allUsers |
Custom Queries
Parameter | Purpose | Example |
---|---|---|
where | The query condition to run |
|
Joins
Parameter | Purpose | Example |
---|---|---|
join | Object containing join definitions | Each join is defined as a key-value pair with table name and join config |
table | The name of the table being joined | ”event_log” |
where | The conditional query to perform when matching records in the join | $db.user.id == $db.event_log.user_id |
Sorting
Parameter | Purpose | Example |
---|---|---|
sort | Object defining sort order for the query results | {user.name: "asc"} |
Evals
Parameter | Purpose | Example |
---|---|---|
eval | Object defining computed fields to add to the response | {user_action: $db.event_log.action} |
Customizing the Response
Parameter | Purpose | Example |
---|---|---|
output | Array of fields returned to display in the response | [“id”, “name”, “email”] |
Return Options
Return Type
Returns are defined using thereturn
parameter with type and configuration options.
-
exists - Returns true/false if records exist
-
-
count - Returns the number of records found
-
-
single - Returns the first record found
-
-
list - Returns an array of records
-
-
stream - Returns records for efficient iteration
-
Return any user records with an ID that matches the input userId
Return any user records with an ID that matches the input userId that are also admins
Get Record
Simple query
Parameter | Description | Example |
---|---|---|
field_name | Uses the specified column to search against | id |
field_value | Uses the value to search the specified column to retrieve a found match | 1 |
as | The variable name that holds the record found | foundRecord |
Customizing the Response
Parameter | Purpose | Example |
---|---|---|
output | The list of fields returned to display in the response. | [“id”, “created_at”, “user”] |
Get a record by ID
Has Record
Parameter | Purpose | Example |
---|---|---|
field_name | The field to search for the record | id |
field_value | The value to match in the search field | $input.id |
Example

Add Record
Parameter | Purpose | Example |
---|---|---|
data | Object containing the fields and values for the new record | {name: "John", email: "john@example.com"} |
Create a new user record
Edit Record
Edits the contents of an existing record in the database by specifying the target record and the data to update.
Parameter | Description | Example |
---|---|---|
field_name | The database field name to search within | id |
field_value | The value to match in the specified field | 1 |
data | Object containing the fields and values to update | {name: 'John', list: ['item1']} |
Update a user's name and list
Update specific fields in a product record
💡 The function will only update the fields specified in the data
object. Other fields in the record will remain unchanged.
Notes
- You must specify which record to update using
field_name
andfield_value
- The
data
object should only include the fields you want to update - You can reference input variables (
$input
) or other variables in your data object - The updated record will be returned in the variable specified after
as
Add or Edit Record
Parameter | Description | Example |
---|---|---|
field_name | Field to search for the record | id |
field_value | Value to match in the search field | 1 |
data | Object containing fields to update/create | {name: 'John'} |
Update or create user profile
Delete Record
Parameter | Purpose | Example |
---|---|---|
field_name | Field to search for the record | ”id” |
field_value | Value to match in the search field | 1 |
Delete inactive user
Patch Record
Parameter | Description | Example |
---|---|---|
field_name | Field to search for the record | id |
field_value | Value to match in the search field | 1 |
data | Object with fields to patch | {name: 'John'} |
Update only the last_login field
Bulk Operations
Bulk Add Users
Parameter | Description | Example |
---|---|---|
items | Array of records to update | [{id: 1, name: 'John'}, {id: 2, name: 'Jane'}] |
Bulk Update Users
Parameter | Description | Example |
---|---|---|
items | Array of records to patch | [{id: 1, name: 'John'}, {id: 2, name: 'Jane'}] |
Bulk Patch Users
Parameter | Description | Example |
---|---|---|
search | Query condition for deletion | $db.user.id >= 100 |
Bulk Delete Users
💡 Bulk operations are more efficient than performing multiple individual operations when working with multiple records.Notes
- All operations return the affected record(s) in the variable specified after
as
- Bulk operations can significantly improve performance when working with multiple records
- The
field_name
andfield_value
combination is used to identify specific records - Patch operations are useful when you want to update specific fields without affecting others
- The
|set:
operator in patch operations allows you to update only specified fields, leaving others unchanged. For example,data = {}|set:"name":$input.name
will only update thename
field in the record. - Always use valid table and field names as defined in your Xano database.
- You can reference input variables (
$input
) or other variables in your data object for dynamic updates. - For best performance, prefer bulk operations when working with many records instead of looping single operations.