Skip to main content

Count Rows In Database

Controlled node

Overview

The Count Rows In Database node queries an Intellectible project database and returns the total number of rows in a specified table. This is useful for validating data imports, checking table sizes, or implementing conditional logic that depends on whether records exist in a table.

The node supports both manual selection via the UI panel (Database Picker and Table Picker) and dynamic input via data connections, allowing you to programmatically specify which database and table to query during workflow execution.

Inputs

InputTypeDescriptionDefault
RunEventTriggers the row count operation.-
Database IDDataThe unique identifier of the database containing the target table. Accepts a database ID string. Can be configured via the Database Picker UI or provided as an input connection.-
Table IDDataThe name or identifier of the table to count rows in. Accepts a table name string. Can be configured via the Table Picker UI or provided as an input connection.-

Outputs

OutputTypeDescription
DoneEventFires when the count operation completes, regardless of success or failure.
CountDataContains the number of rows in the specified table (integer). If an error occurs (invalid inputs, missing project context, or database connection failure), returns an error object with an error property containing the error message.

Runtime Behavior and Defaults

When the Run event fires, the node performs the following operations:

  1. Input Validation: Validates that databaseId and tableId are non-empty strings. Also verifies that the runtime project ID is available from the workflow context.
  2. Database Query: Executes a COUNT(*) query against the specified table using the Intellectible database system.
  3. Output:
    • On success: Outputs the row count as an integer to the Count output.
    • On empty table: Returns 0.
    • On error: Returns an object with an error property describing the failure (e.g., "Database ID must be a valid string", "Project ID could not be determined", or database connection errors).

Note: If inputs are provided via connections, the UI pickers are hidden. If inputs are not connected, the node displays Database Picker and Table Picker controls in the properties panel for manual selection.

Example Usage

Basic Table Check: Connect a Start node to the Run input of Count Rows In Database. Configure the Database ID and Table ID using the UI pickers. Connect the Count output to a Show node to display the total number of records in your table.

Conditional Processing: Connect the Count output to a Compare node to check if count > 0. Use the If node to branch your workflow: if records exist, process them with Read Database; if empty, skip processing or trigger a data import routine.

Dynamic Table Selection: Instead of using the UI pickers, connect a Variable or Text node to the Database ID and Table ID inputs to dynamically specify which table to count based on earlier workflow logic or user input.