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 on our website.
Traits related to relationships between multiple tables.
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.
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.
Provides functions for maintaining database schema.
Re-exports important traits and types. Meant to be glob imported when using Diesel.
Contains traits responsible for the actual construction of SQL statements
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
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.
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
Defines a one-to-many association for the parent table. This macro is only required if you need
to join between the two tables. This macro should be called with the name of the child table,
followed by any options, followed by the entire struct body. The struct must be annotated with
Takes a query
This macro will read your migrations at compile time, and embed a module you can use to execute them at runtime without the migration files being present on the file system. This is useful if you would like to use Diesel's migration infrastructure, but want to ship a single executable file (such as for embedded applications). It can also be used to apply migrations to an in memory database (Diesel does this for its own test suite).
Queries the database for the names of all tables, and calls
Establishes a database connection at compile time, loads the schema
information about a table's columns, and invokes
Useful for libraries adding support for new SQL types. Apps should never need to call this
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
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
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
Useful for libraries adding support for new SQL types. Apps should never need to call this.
Takes takes a query
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.
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
Creates a delete statement. Will delete the records in the given set. Because this function has a very generic name, it is not exported by default.
Creates an insert statement. Will add the given data to a table. This function is not exported by default. As with other commands, the resulting query can return the inserted rows if you choose.
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.
Creates an update statement. Helpers for updating a single row can be
generated by deriving