Connection.findOne

Returns the requested structure, searches by the specified filter with given params

The filter is not further escaped, so programmer needs to make sure not to properly escape or enclose reserved keywords (like user -> "user") so PostgreSQL can understand them.

If not rows are returned, a Nullable null value is returned

  1. Nullable!T findOne(U id)
  2. Nullable!T findOne(string filter, U vals)
    struct Connection
    Nullable!T
    findOne
    (
    T
    U...
    )
    (
    string filter
    ,)

Examples

Connection conn; // An established connection
struct User
{
	@serial @PKey int id;
	string username;
	int posts;
};

auto user = conn.findOne!User("username = $1 OR posts > $2", "foo", 42);
if (!user.isNull)
{
	... // do something
}

Meta