breezedb makes use of a single file in order to create a database, organizing the data in tables and fields:
This file is stored using a JSON structure. An example of this would be:
{
"table_1": {
"fields": [
{
"id": "int"
},
{
"name": "str"
},
{
"name2": "str"
}
],
"rows": [
{
"id": 0,
"name": "Name1",
"name2": "Name2"
},
{
"id": 23,
"name": "Name12",
"name2": "Name21"
}
]
}
}
The root of the database is a simple dictionary. The keys added to this dictionary are tables and there cannot be two tables with the same name.
Tables have two different keys: fields and rows:
For example:
"table_1": {
"fields": [
{
"id": "int"
},
{
"name": "str"
},
{
"location": "str"
},
{
"number": "int"
}
],
"rows": [
{
"id": 234,
"location": "Paris",
"name": "Person 1",
"number": 123456789
},
{
"id": 5371,
"location": "248795641",
"name": "Person 2",
"number": 123456789
},
{
"id": 234,
"location": "Berlin",
"name": "Person 3",
"number": 875469853
}
]
}
Would result in a structure similar to this:
| id | name | location | number |
|---|---|---|---|
| 234 | Person 1 | Paris | 123456789 |
| 5371 | Person 2 | London | 248795641 |
| 4687 | Person 3 | Berlin | 875469853 |
The available data types are:
str: For storing any kind of text, including single characters.
int: For storing integer numbers.
float: For storing real numbers (with double precision).
bool: For storing true/false statements. The boolean type is treated as a single bit (int) for a simpler approach. Therefore:
0 => false
1 => true