[][src]Crate toql

Toql. Transfer Object Query Language

Welcome to Toql API documentation!

This API documentation is very technical and is purely a reference. There is a guide that is better to get started.


The project consists of the following main parts:

  • A Query Parser to build a Toql query from a string.
  • A Query that can be built with methods.
  • A SQL Mapper to map Toql fields to database columns or expressions.
  • A SQL Builder to turn your Toql query into an SQL statement using the mapper.
  • A Toql Derive to build all the boilerplate code to make some ✨ happen.
  • Integration with

Small Example

Using Toql without any dependency features is possible and easy. Here we go:

use toql::{query_parser::QueryParser, sql_mapper::SqlMapper, sql_builder::SqlBuilder};
let query = QueryParser::parse("id, +title LK '%foo%'").unwrap();
let mut mapper = SqlMapper::new("Book b");
        .map_field("id", "b.id")
        .map_field("title", "b.title");

let result = SqlBuilder::new().build(&mapper, &query).unwrap();
assert_eq!("SELECT b.id, b.title FROM Book b WHERE b.title LIKE ? ORDER BY b.title ASC", result.to_sql());

Bigger Example

Have a look at the CRUD example that serves users with Rocket and MySQL.


pub use toql_derive as derive;
pub use log;



Error handling.


Trait to associate a field type provider with a struct.


Insert / Delete / Update


Generic merge function called by code from Toql derive. Used to merge a collection of structs into another collection of structs by equal keys


This module contains the query and all functions to build one programatically.


The query parser can turn a string that follows the Toql query syntax into a Query.


The SQL Builder turns a Query with the help of a SQL Mapper into a SQL Builder Result The result hold the different parts of an SQL query and can be turned into an SQL query that can be sent to the database.


Result of SQL Builder. Use it to get SQL that can be sent to the database.


The SQL Mapper translates Toql fields into database columns or SQL expressions.

Type Definitions


A result with a ToqlError