Basic constructor. RelationProxy requires a connection to operate on.
Convenience alias, allows us to do proxy.where(..).and(...)
Selects the count of records with current filters. Default is *, but any column can be specified as a parameter. The column name is not further escaped.
Same as above, but always searches by the primary key
Finds a single record matching the filters. Equivalent to where(...).first.
Inserts a new record, takes the record as a reference in order to update its PK value. Does not update any other values.
Reloads the content with existing filters.
Removes a single record, filtering it by the primary key's value.
Simply deletes all the records matching the filters.
Updates the given record in the DB with all the current values.
Update all the records matching filters to new values from the AA.
Specifies filters according to the given AA. Filters will be joined with AND.
Same as above, but allowing you to specify a completely custom filter. The supplied string will be wrapped in (), can be called multiple times to specify multiple filters.
Returns the actual content, executing the query if data has not yet been fetched from the database.
Makes a copy of just the filters, not any content;
Fetches the first record matching the filters.
Same as first, but defaults to desceding order, giving you the last match.
Inserts an OR seperator between the filters.
A basic toString implementation, mostly here to prevent querying when the object is implicitly converted to a string.
1 struct User 2 { 3 // provides where, find, findBy, etc on the User struct 4 mixin RelationMixin; 5 6 @PK @serial int id string username; 7 } 8 9 auto user1 = User.where(["id": 1]).first; 10 // Or better yet. Search directly by PK 11 auto betterUser1 = User.find(1); 12 // Delete some users 13 long nDeleted = User.where("username LIKE 'somethi%'").removeAll();
A structure proxying to the actual Postgres table.
Allows short and readable querying, returning actual records or arrays of them. first, last, and all will be cached if appropriate, the rest will execute a query whenever a result is needed. Most functions return a reference to the same object, allowing you to chain them. Builder pattern, really.
Can be implicitly converted to an array of the requested structure.
Mostly meant to be used with RelationMixin, but can be used manually.