Schema
The GitQL parser and engine should be aware of what kind of data it should deal with, so it can provide
a clean error messages, and apply the right operators, this information defined in a structure way in place called
the Schema
, and this schema contains
- What tables you have.
- What are the columns in each tables and what are their types.
pub struct Schema {
pub tables_fields_names: HashMap<&'static str, Vec<&'static str>>,
pub tables_fields_types: HashMap<&'static str, Box<dyn DataType>>,
}
So for your custom purpose you need to define your own schema, let take an example of a simple file system,
so you have a table called files
, and this table has two columns, file_name
as Text (aka String), and is_directory
as Boolean.
Define the columns types
Define the table name and his columns
Create a schema object with those information
Later this schema instance with the standard library will used to create the environment