SiYuan icon

SiYuan

Manage SiYuan notebooks, documents, blocks, attributes, and more. Designed for AI agent workflows.

Database → Get

AI-generated

Overview

This node operation retrieves data from a SiYuan database, specifically from an AttributeView block identified by its AV ID. It allows users to fetch rows from the database with optional client-side filtering using JSON. The output can be shaped in two modes: 'split', which returns one item per row with flat column-name keys, or 'single', which returns one item per input containing the schema, rows array, and row count. This operation is useful for querying and extracting structured data from SiYuan databases for further processing or conditional logic in workflows.

Use Case Examples

  1. Fetching all rows from a specific AttributeView to process each row individually using the 'split' output mode.
  2. Checking if any rows match certain criteria by using the 'single' output mode and examining the rowCount to branch logic accordingly.

Properties

Name Meaning
AV ID The AttributeView ID of the database block to query, used to identify which database to fetch data from.
Output Mode Determines how the output data is structured: 'split' returns one item per row, 'single' returns one item per input with schema and rows.
Filter (JSON) Optional JSON object for client-side filtering of rows after fetching. Supports scalar equality and array-based OR matching within columns.

Output

JSON

  • schema - The schema of the database table, describing columns.
  • rows - An array of rows fetched from the database, each row is a flat object keyed by column names.
  • rowCount - The number of rows returned by the query.

Dependencies

  • SiYuan API URL and Token credentials required for authentication.

Troubleshooting

  • Ensure the AV ID is correct and corresponds to an existing AttributeView block; otherwise, no data will be returned.
  • If using 'split' output mode, be aware that no items are emitted when no rows match the filter, which can cause silent drops in batch processing.
  • Verify that the SiYuan API URL and Token credentials are correctly set; missing or invalid credentials will cause operation failure.

Discussion