Expand description
§Agrum
Agrum is a database access layers designed to let developpers:
- to write the SQL they want so they can directly populate their aggregates from the database
- to focus on the business value of the queries
- 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§
- Entity
Stream - A stream of entities.
- Projection
- A Projection defines what is output from a query in order to hydrate a [SQLEntity]
- Projection
Field Definition - 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_variablemethod to set the variables and theadd_parametermethod to add the parameters. The query is expanded using theexpandmethod to get the SQL query and the parameters. - Structure
- Structure of a SQL tuple.
- Structure
Field - 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.
- Where
Condition - 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_whereandor_wheremethods with a default representation oftrueif no condition is provided.
Enums§
- Hydration
Error - Error raised during entity hydration process.
Traits§
- Delete
Query Book - A trait that marks QueryBooks that perform
delete from {:source:} where {:condition:} returning {:projection:}queries. These queries actually return the deleted entities. - Insert
Query Book - A trait that marks QueryBooks that perform SQL insert queries. These queries actually return the inserted entities.
- Query
Book - 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.
- Read
Query Book - 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.
- ToSql
Any - A trait to mark types that can be converted to a
ToSqltype and also implementAnyandSync. This trait is used for the parameters of the queries. - Update
Query Book - A trait that marks QueryBooks that perform simple aSQL update queries These queries actually return the updated entities.