Database Lookup (Single)

BlockDatabases

Find a single row from a database matching your query. Returns the first matching row.

  • Gets an extra input or output for each column of the database you pick.

Inputs

DatabaseRequired

Select the database to query.

Query

Define filters to find the row. Leave empty to get the first row.

Set up in the editor. The JSON format is under advanced documentation below.

Outputs

Row ID

The unique ID of the found row.

Example: abc123xyz

Found

Whether a matching row was found (true/false).

Example: true

Row JSON

The full row as a JSON object, including system fields (__id, __created_at, __updated_at, __created_at_unix, __updated_at_unix).

Example: {"__id":"abc123","name":"example"}

Build a bot using blocks like Database Lookup (Single)

Use this block in our visual flow editor. Bots are hosted 24/7 for free on inventor.bot.

Advanced Documentation

This documentation can be useful when using code mode. View as Markdown

ID: db_lookup_single
  • Database columns are extra inputs/outputs named dbcol_<column name>.

Inputs

FieldInventScript nameValue
Databasedatabase_id
Queryquery_jsonJSON text
query_json format: JSON text of type DatabaseQuery. Fields marked ? are optional.
type DatabaseQuery = {
	where?: FilterGroup
	sort?: SortClause[]
	limit?: number
	offset?: number
}

type FilterGroup = {
	logic: string // "and" or "or"
	conditions: FilterCondition[]
}

type FilterCondition = {
	type: string // "comparison" or "group"
	columnId?: string // comparison only
	operator?: string // comparison only: eq, neq, gt, gte, lt, lte, contains, not_contains, starts_with, ends_with, is_empty, is_not_empty
	value?: string // comparison only
	group?: FilterGroup // group only
}

type SortClause = {
	columnId: string
	direction: string // "asc", "desc" or "random"
}

Outputs

FieldInventScript nameValue
Row IDrow_ide.g. "abc123xyz"
Foundfounde.g. "true"
Row JSONrow_jsone.g. "{\"__id\":\"abc123\",\"name\":\"example\"}"

Example InventScript

row := db_lookup_single(Args{database_id: "..."})
send_text_message(Args{channel_id: trigger.channel_id, message_content: "Row ID: " + row.row_id})

More databases blocks