Struct ResultRange

An input range interface to access the rows resulting from an SQL query.

struct ResultRange ;

The elements of the range are Row structs. A Row is just a view of the current row when iterating the results of a ResultRange. It becomes invalid as soon as ResultRange.popFront() is called (it contains undefined data afterwards). Use cached to store the content of rows past the execution of the statement.

Instances of this struct are typically returned by Database.execute() or Statement.execute().

Properties

NameTypeDescription
empty[get] boolRange interface.
front[get] RowRange interface.

Methods

NameDescription
oneValue () Gets only the first value of the first row returned by the execution of the statement.
popFront () Range interface.

Example

auto db = Database(":memory:");
db.run("CREATE TABLE test (i INTEGER);
        INSERT INTO test VALUES (1);
        INSERT INTO test VALUES (2);");

auto results = db.execute("SELECT * FROM test");
assert(!results.empty);
assert(results.front.peek!long(0) == 1);
results.popFront();
assert(!results.empty);
assert(results.front.peek!long(0) == 2);
results.popFront();
assert(results.empty);