QuestDB Node.js Client - v4.2.0
    Preparing search index...

    Interface SenderBuffer

    Buffer used by the Sender for data serialization.
    Provides methods for writing different data types into the buffer.

    interface SenderBuffer {
        reset(): SenderBuffer;
        toBufferView(pos?: number): Buffer;
        toBufferNew(pos?: number): Buffer<ArrayBufferLike>;
        table(table: string): SenderBuffer;
        symbol(name: string, value: unknown): SenderBuffer;
        stringColumn(name: string, value: string): SenderBuffer;
        booleanColumn(name: string, value: boolean): SenderBuffer;
        floatColumn(name: string, value: number): SenderBuffer;
        arrayColumn(name: string, value: unknown[]): SenderBuffer;
        intColumn(name: string, value: number): SenderBuffer;
        timestampColumn(
            name: string,
            value: number | bigint,
            unit?: TimestampUnit,
        ): SenderBuffer;
        decimalColumnText(name: string, value: string | number): SenderBuffer;
        decimalColumn(
            name: string,
            unscaled: bigint | Int8Array<ArrayBufferLike>,
            scale: number,
        ): SenderBuffer;
        at(timestamp: number | bigint, unit?: TimestampUnit): void;
        atNow(): void;
        currentPosition(): number;
    }
    Index

    Methods

    • Resets the buffer, data sitting in the buffer will be lost. In other words it clears the buffer, and sets the writing position to the beginning of the buffer.

      Returns SenderBuffer

      Returns with a reference to this buffer.

    • Returns a cropped buffer, or null if there is nothing to send. The returned buffer is backed by this buffer instance, meaning the view can change as the buffer is mutated. Used only in tests to assert the buffer's content.

      Parameters

      • Optionalpos: number

        Optional position parameter

      Returns Buffer

      A view of the buffer

    • Returns a cropped buffer ready to send to the server, or null if there is nothing to send. The returned buffer is a copy of this buffer. It also compacts the buffer.

      Parameters

      • Optionalpos: number

        Optional position parameter

      Returns Buffer<ArrayBufferLike>

      A copy of the buffer ready to send, or null

    • Writes a symbol name and value into the buffer. Use it to insert into SYMBOL columns.

      Parameters

      • name: string

        Symbol name.

      • value: unknown

        Symbol value, toString() is called to extract the actual symbol value from the parameter.

      Returns SenderBuffer

      Returns with a reference to this buffer.

    • Writes a string column with its value into the buffer. Use it to insert into VARCHAR and STRING columns.

      Parameters

      • name: string

        Column name.

      • value: string

        Column value, accepts only string values.

      Returns SenderBuffer

      Returns with a reference to this buffer.

    • Writes a boolean column with its value into the buffer. Use it to insert into BOOLEAN columns.

      Parameters

      • name: string

        Column name.

      • value: boolean

        Column value, accepts only boolean values.

      Returns SenderBuffer

      Returns with a reference to this buffer.

    • Writes a 64-bit floating point value into the buffer. Use it to insert into DOUBLE or FLOAT database columns.

      Parameters

      • name: string

        Column name.

      • value: number

        Column value, accepts only number values.

      Returns SenderBuffer

      Returns with a reference to this buffer.

    • Writes an array column with its values into the buffer.

      Parameters

      • name: string

        Column name

      • value: unknown[]

        Array values to write (currently supports double arrays)

      Returns SenderBuffer

      Returns with a reference to this buffer.

      Error if arrays are not supported by the buffer implementation, or array validation fails:

      • value is not an array
      • or the shape of the array is irregular: the length of sub-arrays are different
      • or the array is not homogeneous: its elements are not all the same type
    • Writes a 64-bit signed integer into the buffer. Use it to insert into LONG, INT, SHORT and BYTE columns.

      Parameters

      • name: string

        Column name.

      • value: number

        Column value, accepts only number values.

      Returns SenderBuffer

      Returns with a reference to this buffer.

      Error if the value is not an integer

    • Writes a timestamp column and its value into the buffer.

      Use this method to insert data into TIMESTAMP or TIMESTAMP_NS columns.

      Precision rules:

      • Protocol v2 and higher: Timestamps passed with unit 'ns' (nanoseconds) are sent with full nanosecond precision. All other timestamps are sent with microsecond precision.
      • Protocol v1: Always uses microsecond precision, even if the timestamp is specified in nanoseconds.

      Parameters

      • name: string

        The column name.

      • value: number | bigint

        The epoch timestamp. Must be an integer or a BigInt.

      • Optionalunit: TimestampUnit

        The time unit of the timestamp. Supported values:

        • 'ns' — nanoseconds (requires BigInt)
        • 'us' — microseconds (default)
        • 'ms' — milliseconds

      Returns SenderBuffer

      Returns with a reference to this buffer.

      If value is not an integer or BigInt.

      If unit is 'ns' but value is not a BigInt.

    • Writes a decimal value into the buffer using its text format.

      Use it to insert into DECIMAL database columns.

      Parameters

      • name: string

        Column name.

      • value: string | number

        The decimal value to write.

        • Accepts either a number or a string containing a valid decimal representation.
        • String values should follow standard decimal notation (e.g., "123.45" or "-0.001").

      Returns SenderBuffer

      Returns with a reference to this buffer.

      Error If decimals are not supported by the buffer implementation, or validation fails. Possible validation errors:

      • The provided string is not a valid decimal representation.
    • Writes a decimal value into the buffer using its binary format.

      Use it to insert into DECIMAL database columns.

      Parameters

      • name: string

        Column name.

      • unscaled: bigint | Int8Array<ArrayBufferLike>

        The unscaled integer portion of the decimal value.

        • If a bigint is provided, it will be converted automatically.
        • If an Int8Array is provided, it must contain the two’s complement representation of the unscaled value in big-endian byte order.
        • An empty Int8Array represents a NULL value.
      • scale: number

        The number of fractional digits (the scale) of the decimal value.

      Returns SenderBuffer

      Returns with a reference to this buffer.

      If decimals are not supported by the buffer implementation, or validation fails. Possible validation errors:

      • unscaled length is not between 0 and 32 bytes.
      • scale is not between 0 and 76.
      • unscaled contains invalid bytes.
    • Closes the row after writing the designated timestamp into the buffer.

      Precision rules:

      • Protocol v2 and higher: Timestamps passed with unit 'ns' (nanoseconds) are sent with full nanosecond precision. All other timestamps are sent with microsecond precision.
      • Protocol v1: Always uses microsecond precision, even if the timestamp is specified in nanoseconds.

      Parameters

      • timestamp: number | bigint

        Designated epoch timestamp. Must be an integer or a BigInt.

      • Optionalunit: TimestampUnit

        The time unit of the timestamp. Supported values:

        • 'ns' — nanoseconds (requires BigInt)
        • 'us' — microseconds (default)
        • 'ms' — milliseconds

      Returns void

      Returns with a reference to this buffer.

      If value is not an integer or BigInt.

      If unit is 'ns' but value is not a BigInt.

    • Closes the row without writing designated timestamp into the buffer. Designated timestamp will be populated by the server on this record.

      Returns void

    • Returns the current position of the buffer. New data will be written into the buffer starting from this position.

      Returns number

      The current write position in the buffer