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 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 or
Statement.
Properties
| Name | Type | Description |
|---|---|---|
empty[get]
|
bool | Range interface. |
front[get]
|
Row | Range interface. |
Methods
| Name | Description |
|---|---|
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);