Query

A nice wrapper around various DB querying functions, to fill even everyday PostgreSQL querying with joy.

Constructors

this
this(string command, Value[] params = [])

Constructs a new Query object, reusing the last opened connection. Will fail if no connection has been established.

this
this(ref Connection conn, string command = "", Value[] params = [])

Like the above constructor, except it also accepts a Connection as the first param. A copy of the Connection is not made.

Members

Functions

addParam
void addParam(T val)

Add a param to the list of params that will be sent with the query. It's probably a better idea to just use run function with all the values, but in some cases, adding params one by one can result in a more readable code.

opAssign
void opAssign(string str)

Sets the query's command and resets the params. Connection is not affected Useful if you want to reuse the same query object.

opBinary
Query opBinary(T val)

In reality just an alias to addParam, but can be chained to add multiple params.

run
Result run()
Result run(T params)

Runs the Query, returning a Result object. Optionally accepts a list of params for the query to be ran with. The params are added to the query, and if the query is re-ran for the second time, do not need to be added again.

runAsync
bool runAsync(T params)

ditto, async

Properties

command
string command [@property getter]
string command [@property setter]

A getter/setter pair for the command that will be executed.

connection
Connection connection [@property setter]

A setter for the connection.

Examples

1 Connection c; // an established connection
2 
3 Query q; // Will not have the connection set (!!!)
4 q.connection = c; // We can set it manually
5 
6 q = Query(c); // Or simply use the constructor

Meta