Row.peek

Returns the data of a column directly.

Contrary to opIndex, the peek functions return the data directly, automatically cast to T, without the overhead of using a wrapping type (ColumnData).

When using peek to retrieve an array or a string, you can use either:

  • peek!(..., PeekMode.copy)(index), in which case the function returns a copy of the data that will outlive the step to the next row, or
  • peek!(..., PeekMode.slice)(index), in which case a slice of SQLite's internal buffer is returned (see Warnings).
  1. T peek(size_t index)
  2. T peek(size_t index)
  3. T peek(size_t index)
  4. T peek(size_t index)
  5. T peek(size_t index)
    struct Row
    T
    peek
    (
    T
    )
    (
    size_t index
    )
    if (
    isInstanceOf!(Nullable, T) &&
    !isArray!(TemplateArgsOf!T[0])
    &&
    !isSomeString!(TemplateArgsOf!T[0])
    )
  6. T peek(size_t index)
  7. T peek(string columnName)

Parameters

T

The type of the returned data. T must be a boolean, a built-in numeric type, a string, an array or a Nullable.

Condition on TRequested database type
isIntegral!T || isBoolean!TINTEGER
isFloatingPoint!TFLOAT
isSomeString!TTEXT
isArray!TBLOB
is(T == Nullable!U, U...)NULL or U
index
Type: size_t

The index of the column in the prepared statement or the name of the column, as specified in the prepared statement with an AS clause. The index of the first column is 0.

Return Value

Type: T

A value of type T. The returned value results from SQLite's own conversion rules: see http://www.sqlite.org/c3ref/column_blob.html and http://www.sqlite.org/lang_expr.html#castexpr. It's then converted to T using std.conv.to!T.

Warnings: When using PeekMode.slice, the data of the slice will be invalidated when the next row is accessed. A copy of the data has to be made somehow for it to outlive the next step on the same statement.

When using referring to the column by name, the names of all the columns are tested each time this function is called: use numeric indexing for better performance.

Meta