beancount
    Preparing search index...

    Class Query

    Represents a Query node that defines a named SQL query. Query directives allow defining reusable queries in the Beancount file.

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new DatedNode instance.

      Parameters

      • obj: { date: string | PlainDate; [key: string]: unknown }

        Object containing node properties

        • [key: string]: unknown
        • date: string | PlainDate

          The date string in YYYY-MM-DD format

      Returns Query

    Properties

    comment?: string

    Optional comment text associated with this node

    date: PlainDate

    The date of this node as a Temporal.PlainDate object

    internalMetadata: Record<string, unknown> = {}

    Internal metadata key-value pairs associated with this node. These can be anything, are not used in the output, and are meant to be used to allow your pipeline to keep track of an internal property

    metadata?: Record<string, Value>

    Optional metadata key-value pairs associated with this node

    name: string

    The name of the query

    sqlContents: string

    The SQL query contents

    type: "query" = ...

    The type of this dated node

    Methods

    • Converts metadata and comment to a formatted string. If metadata exists, each key-value pair is formatted on separate indented lines.

      Returns string

      The formatted metadata and comment string, or empty string if neither exists

    • Transforms JSON data before creating an Node instance. Default implementation returns the input unchanged. Subclasses can override this to handle custom deserialization logic (e.g., converting nested objects, handling dates, etc.).

      Parameters

      • json: Record<string, unknown>

        The JSON data to transform

      Returns Record<string, unknown>

      The transformed data ready for the constructor

    • Converts this node to a formatted string with aligned columns. Default implementation delegates to toString(). Subclasses can override for custom formatting.

      Parameters

      • _formatOptions: FormatOptions = defaultFormatOptions

        Formatting options (unused in base implementation)

      Returns string

      The formatted string representation of this node

    • Converts an node to a JSON-serializable object.

      Returns Record<string, unknown>

      A JSON-serializable representation of this node

    • Creates an Node instance from JSON data. Calls fromJSONData to allow subclasses to transform the data before construction.

      Type Parameters

      Parameters

      • this: new (obj: any) => T
      • jsonString: string

        JSON data representing an node

      Returns T

      A new instance of the Node subclass

      Warning: No validation is performed on the JSON input. We assume the JSON is valid and well-formed.

    • Creates an Node instance from JSON data. Calls fromJSONData to allow subclasses to transform the data before construction.

      Type Parameters

      Parameters

      • this: new (obj: any) => T
      • jsonData: Record<string, unknown>

        object representing an node

      Returns T

      A new instance of the Node subclass

      Warning: No validation is performed on the input. We assume the input is valid and well-formed.

    • Creates an Node instance from a Beancount string. Parses the input string and constructs the appropriate Node subclass.

      Type Parameters

      Parameters

      • this: NodeConstructor<T>
      • input: string

        A single unparsed node as a string

      Returns T

      A new instance of the Node subclass