PreCollection

ORM Query Builder

// pre-compiled query (CTFE)
enum bqMountains = em.find!Mountain()
    .orderBy("height")
    .limit(25)
    .select();

// execute (at runtime)
auto mountains = bqMountains.via(db);
foreach (mt; mountains) {
    // […]
}

For each member function returning a BuiltPreCollection, there’s also a shorthand “via” function. The “via” variant executes the built query via the provided database connection.

auto mountains = em.find!Mountain()
    .orderBy("height")
    .limit(25)
    .selectVia(db);

foreach (mt; mountains) {
    // […]
}

Members

Functions

aggregate
BuiltQuery aggregate(AggregateFunction aggr, string column)
aggregateVia
DBValue aggregateVia(AggregateFunction aggr, string column, DatabaseDriver db)

SELECTs aggregate data for the requested entities from the database

count
BuiltQuery count()
countVia
ulong countVia(DatabaseDriver db)

COUNTs the number of requested entities from the database

deleteVia
void deleteVia(DatabaseDriver db)

DELETEs the requested entities from the database

delete_
BuiltQuery delete_()

DELETEs the requested entities from the database

limit
PreCollection!(TEntity, DatabaseDriver) limit(ulong limit)
PreCollection!(TEntity, DatabaseDriver) limit(ulong limit, int offset)

LIMITs the number of entities to retrieve

orderBy
PreCollection!(TEntity, DatabaseDriver) orderBy(string column, OrderingSequence orderingSequence)

Specifies a sorting criteria for the requested data

select
BuiltPreCollection!TEntity select()
selectVia
EntityCollection!TEntity selectVia(DatabaseDriver db)

SELECTs the requested entities from the database

where
PreCollection!(TEntity, DatabaseDriver) where(string column, TComparisonOperator op, DBValue value)
PreCollection!(TEntity, DatabaseDriver) where(string column, TComparisonOperator op, T value)
PreCollection!(TEntity, DatabaseDriver) where(string column, TComparisonOperator op)
whereParentheses
PreCollection!(TEntity, DatabaseDriver) whereParentheses(Query delegate(Query q) @(safe) pure conditions)

Specifies the filter criteria for the requested data

Meta