Crate diesel [−] [src]
Diesel
Diesel is an ORM and query builder designed to reduce the boilerplate for database interactions.
Crates
- Diesel: core libary, documented here
- Diesel CLI: command line tool that aids in managing your database schema
Reexports
pub use prelude::*; |
pub use result::Error::NotFound; |
Modules
associations |
Traits related to relationships between multiple tables. |
backend | |
connection | |
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). This module will re-export all backend specific data structures when compiled against that backend. |
dsl |
Includes various helper types and bare functions which are named too generically to be included in prelude, but are often used when using Diesel. |
expression |
AST types representing various typed SQL expressions. Almost all types
implement either |
expression_methods |
Adds various methods to construct new expressions. These traits are exported by default, and implemented automatically. |
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. |
mysql |
Provides types and functions related to working with MySQL |
pg |
Provides types and functions related to working with PostgreSQL |
prelude |
Re-exports important traits and types. Meant to be glob imported when using Diesel. |
query_builder |
Contains traits responsible for the actual construction of SQL statements |
query_dsl |
Traits that construct SELECT 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 |
Errors, type aliases, and functions related to working with |
row |
Contains the |
sqlite |
Provides types and functions related to working with SQLite |
types |
Types which represent a native SQL data type, and the conversions between them and Rust primitives. The structs in this module are only used as markers to represent a SQL type, and shouldn't be used in your structs. See the documentation for each type to see the Rust types that can be used with a corresponding SQL type. Additional types can be added by other crates. |
Macros
BelongsTo |
Defines a one-to-one association for the child table. This macro should be
called with the name of the parent struct, followed by any options, followed
by the entire struct body. The struct must be annotated with
|
allow_tables_to_appear_in_same_query |
Allow two or more tables which are otherwise unrelated to be used together in a query. |
diesel_infix_operator |
Useful for libraries adding support for new SQL types. Apps should never need to call this. |
diesel_postfix_operator |
Useful for libraries adding support for new SQL types. Apps should never need to call this. |
diesel_prefix_operator |
Useful for libraries adding support for new SQL types. Apps should never need to call this. |
impl_AsChangeset |
Implements the |
impl_Identifiable |
Implements the |
impl_Insertable |
Implements the |
joinable |
Allow two tables to be referenced in a join query without providing an
explicit |
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 |
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 |
Functions
debug_query |
Takes a query |
delete |
Creates a |
insert_into |
Creates an |
replace_into |
Creates a |
select |
Creates a bare select statement, with no from clause. Primarily used for testing diesel itself, but likely useful for third party crates as well. The given expressions must be selectable from anywhere. |
sql_query |
Construct a full SQL query using raw SQL. |
update |
Creates an |