Row.as

Returns a struct with field members populated from the row's data.

Neither the names of the fields nor the names of the columns are checked. The fields are filled with the columns' data in order. Thus, the order of the struct members must be the same as the order of the columns in the prepared statement.

SQLite's conversion rules will be used. For instance, if a string field has the same rank as an INTEGER column, the field's data will be the string representation of the integer.

struct Row
T
as
(
T
)
()
if (
is(T == struct)
)

Examples

struct Item
{
    int _id;
    string name;
}

auto db = Database(":memory:");
db.run("CREATE TABLE items (name TEXT);
        INSERT INTO items VALUES ('Light bulb')");

auto results = db.execute("SELECT rowid AS id, name FROM items");
auto row = results.front;
auto thing = row.as!Item();

assert(thing == Item(1, "Light bulb"));

Meta