Argument to condition. Callback that takes in a ConditionBuilder!T and returns a Condition that can easily be created using that builder.
Argument to orderBy. Callback that takes in an OrderBuilder!T and returns the ffi ordering value that can be easily created using the builder.
Argument to populate. Callback that takes in an OrderBuilder!T and returns the ffi ordering value that can be easily created using the builder.
Fetches all result data into one array. Uses the GC to allocate the data, so it's not needed to keep track of how long objects live by the user.
Limits the query to only rows matching this condition. Maps to the WHERE clause in an SQL statement.
Returns the first row of the result data or throws if no data exists.
Returns the first row of the result data or throws if no data exists.
Sets the maximum number of rows to return. Using this method disables the findOne and findOptional methods.
Sets the offset. (number of rows after which to return from the database)
Implementation detail, makes it possible to use [start .. end] on the select struct to set both offset and limit at the same time.
Implementation detail, makes it possible to use [start .. end] on the select struct to set both offset and limit at the same time.
Allows ordering by the specified field with the specified direction. (defaults to ascending)
Eagerly loads the data for the specified foreign key ModelRef fields when executing the query.
Implementation detail, makes it possible to use [start .. end] on the select struct to set both offset and limit at the same time.
Fetches all data into a range that can be iterated over or processed with regular range functions. Does not allocate an array to store the fetched data in, but may still use sparingly the GC in implementation.
This is the builder struct that's used for select operations (queries)
Don't construct this struct manually, use the db.select or tx.select method (UFCS method defined globally) to create this struct.
Methods you can call on this builder to manipulate the result:
The following methods are implemented for restricting queries: (most can only be called once, which is enforced through the template parameters) - condition is used to set the "WHERE" clause in SQL. It can only be called once on any query operation. - limit can be used to set a maximum number of rows to return. When this restriction is called, findOne and findOptional can no longer be used. - offset can be used to offset after how many rows to start returning. - orderBy can be used to order how the results are to be returned by the database.
The following methods are important when working with ModelRef / foreign keys: - populate eagerly loads data from a foreign model, (re)using a join
Finishing methods you can call on this builder:
The following methods can be used to extract the data: - stream to asynchronously stream data. (can be used as iterator / range) - array to eagerly fetch all data and do a big memory allocation to store all the values into. - findOne to find the first matching item or throw for no data. - findOptional to find the first matching item or return Nullable!T.init for no data.
There are restrictions when stream/array as well as when findOne/findOptional can be used:
stream/array are usable when: - neither limit and offset are set - both limit and offset are set - only limit is set and offset is not set
findOne/findOptional are only usable when no limit is set.