Skip to main content

Crate agrum

Crate agrum 

Source
Expand description

§Agrum

Agrum is a database access layers designed to let developpers:

  1. to write the SQL they want so they can directly populate their aggregates from the database
  2. to focus on the business value of the queries
  3. to test the queries they write

This library is still in early development stage, means it is not production ready. If you are looking for a mature solution, have a look at Elephantry

Macros§

params
A macro to create a vector of parameters. This macro is used to create the parameters of the queries.

Structs§

EntityStream
A stream of entities.
Projection
A Projection defines what is output from a query in order to hydrate a [SQLEntity]
ProjectionFieldDefinition
Definition of a projection field.
SqlQuery
A query builder. This is the main structure to build the SQL queries using a templating system. It is designed to be a composable structure to build the SQL queries alongside the according parameters. The query is built using the set_variable method to set the variables and the add_parameter method to add the parameters. The query is expanded using the expand method to get the SQL query and the parameters.
Structure
Structure of a SQL tuple.
StructureField
SQL field structure.
Transaction
A transaction wrapper. This is mainly to enforce the transaction management by the caller. There is a bit of cabling in the query method to pass the parameters and instantiate the stream.
WhereCondition
A structure to hold the where condition of the queries. It is designed to be a composable structure to build the where condition of the queries alongside the according parameters, preserving the order of the parameters. The conditions are composed using the and_where and or_where methods with a default representation of true if no condition is provided.

Enums§

HydrationError
Error raised during entity hydration process.

Traits§

DeleteQueryBook
A trait that marks QueryBooks that perform delete from {:source:} where {:condition:} returning {:projection:} queries. These queries actually return the deleted entities.
InsertQueryBook
A trait that marks QueryBooks that perform SQL insert queries. These queries actually return the inserted entities.
QueryBook
A trait to mark types that are query books. Query books are responsible of building the queries that will be sent to the database server. This is the place where SQL templates are defined and populated with the parameters. By essence, a QueryBook takes its data from a SQL source and defines the SQL computation that will return the data.
ReadQueryBook
A trait that marks QueryBooks that perform simple select {:projection:} from {:source:} where {:condition:} queries.
SqlEntity
A trait to mark types that are SQL entities. An SQL entity is a type that has a structure, a projection and a hydration function.
Structured
A trait to mark types that are structured. A structured type is a type that has a structure. The structure is a list of fields with their names and SQL types.
ToSqlAny
A trait to mark types that can be converted to a ToSql type and also implement Any and Sync. This trait is used for the parameters of the queries.
UpdateQueryBook
A trait that marks QueryBooks that perform simple aSQL update queries These queries actually return the updated entities.