Crate diesel [−] [src]
Diesel is an ORM and query builder designed to reduce the boilerplate for database interactions. A getting started guide can be found in the README.
Reexports
pub use expression::{Expression, SelectableExpression, BoxableExpression}; |
pub use expression::expression_methods::*; |
pub use query_source::{QuerySource, Queriable, Table, Column}; |
pub use result::{QueryResult, TransactionError, TransactionResult, ConnectionError, ConnectionResult, OptionalExtension}; |
pub use result::Error::NotFound; |
Modules
data_types |
Structs to represent the primitive equivalent of SQL types where there is no existing Rust primitive, or where using it would be confusing (such as date and time types) |
expression |
AST types representing various typed SQL expressions. Almost all types
implement either |
helper_types |
Provide helper types for concisely writing the return type of functions. As with iterators, it is unfortunately difficult to return a partially constructed query without exposing the exact implementation of the function. Without higher kinded types, these various DSLs can't be combined into a single trait for boxing purposes. |
migrations |
Provides functions for maintaining database schema. |
query_builder |
Contains traits responsible for the actual construction of SQL statements |
query_source |
Types in this module are mostly internal and automatically generated. You
shouldn't need to interact with these types during normal usage, other than
the methods on |
result | |
types |
Types which represent a native SQL data type, and the conversions between them and Rust primitives. Additional types can be added by other crates. |
Macros
debug_sql! |
Takes a query QueryFragment expression as an argument and returns a string of SQL with placeholders for the dynamic values. |
infix_predicate! |
Useful for libraries adding support for new SQL types. Apps should never need to call this |
no_arg_sql_function! |
Declare a 0 argument SQL function for use in your code. This will generate a
unit struct, which is an expression representing calling this function. See
|
numeric_expr! |
Indicates that an expression allows all numeric operators. If you create new
SQL functions that return a numeric type, you should invoke this macro that
type. Unfortunately, Rust disallows us from automatically implementing |
operator_allowed! |
Implements the Rust operator for a given type. If you create a new SQL
function, which returns a type that you'd like to use an operator on, you
should invoke this macro. Unfortunately, Rust disallows us from
automatically implementing |
postfix_predicate! |
Useful for libraries adding support for new SQL types. Apps should never need to call this. |
print_sql! |
Takes takes a query QueryFragment expression as an argument and prints out the SQL with placeholders for the dynamic values. |
sql_function! |
Declare a sql function for use in your code. Useful if you have your own SQL functions that
you'd like to use. You can optionally provide a doc string as well. |
table! |
Specifies that a table exists, and what columns it has. This will create a
new public module, with the same name, as the name of the table. In this
module, you'll find a unit struct named |
Structs
Connection | |
Cursor |
The type returned by various |
Traits
BelongingToDsl | |
CountDsl |
Adds a simple |
ExecuteDsl | |
FilterDsl |
Adds to the |
Insertable |
Represents that a structure can be used to to insert a new row into the database.
Implementations can be automatically generated by
|
JoinTo |
Indicates that two tables can be used together in a JOIN clause. Implementations of this trait will be generated for you automatically by the association annotations from codegen. |
LimitDsl |
Sets the limit clause of a query. If there was already a limit clause, it will be overridden. This is automatically implemented for the various query builder types. |
LoadDsl |
Methods to execute a query given a connection. These are automatically implemented for the various query types. |
OffsetDsl |
Sets the offset clause of a query. If there was already a offset clause, it will be overridden. This is automatically implemented for the various query builder types. |
OrderDsl |
Sets the order clause of a query. If there was already a order clause, it
will be overridden. The expression passed to |
SelectDsl |
Sets the select clause of a query. If there was already a select clause, it
will be overridden. The expression passed to |
WithDsl |
Adds an additional expression to the FROM clause. This is useful for things
like full text search, where you need to access the result of an expensive
computation for the where clause that shouldn't be redone for each row, such
as |