docs categorized documentation
- moved docs to categories - updated all links [skip ci]
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Prologue
|
||||
sidebar_position: 0
|
||||
sidebar_label: 🔥 Prologue
|
||||
slug: /
|
||||
hide_table_of_contents: true
|
||||
description: TinyORM is a modern c++ ORM library that makes interacting with a database extremely simple. It depends on the QtCore and QtSql libraries. The code is written in the modern c++20 way and is well tested with the unit and functional tests.
|
||||
@@ -14,12 +14,12 @@ The code is written in the modern c++20 way and is well tested with the unit and
|
||||
|
||||
- [Dependencies](dependencies.mdx)
|
||||
- [Supported Compilers](supported-compilers.mdx)
|
||||
- [Database: Getting Started](database.mdx)
|
||||
- [Database: Query Builder](query-builder.mdx)
|
||||
- [Database: Migrations](migrations.mdx)
|
||||
- [Database: Seeding](seeding.mdx)
|
||||
- [TinyORM: Getting Started](tinyorm.mdx)
|
||||
- [TinyORM: Relationships](tinyorm-relationships.mdx)
|
||||
- [Building: TinyORM](building-tinyorm.mdx)
|
||||
- [Building: Hello world](building-hello-world.mdx)
|
||||
- [Building: Migrations](building-migrations.mdx)
|
||||
- [Database: Getting Started](database/getting-started.mdx)
|
||||
- [Database: Query Builder](database/query-builder.mdx)
|
||||
- [Database: Migrations](database/migrations.mdx)
|
||||
- [Database: Seeding](database/seeding.mdx)
|
||||
- [TinyORM: Getting Started](tinyorm/getting-started.mdx)
|
||||
- [TinyORM: Relationships](tinyorm/relationships.mdx)
|
||||
- [Building: TinyORM](building/tinyorm.mdx)
|
||||
- [Building: Hello world](building/hello-world.mdx)
|
||||
- [Building: Migrations](building/migrations.mdx)
|
||||
|
||||
2
docs/building/_category_.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
position: 5
|
||||
label: '🚧 Building'
|
||||
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
@@ -1,5 +1,6 @@
|
||||
---
|
||||
sidebar_position: 10
|
||||
sidebar_position: 2
|
||||
sidebar_label: Hello world
|
||||
description: Hello world example created in the terminal and QtCreator IDE.
|
||||
---
|
||||
|
||||
@@ -40,7 +41,7 @@ import {
|
||||
|
||||
We will try to create the simplest working application in the terminal with the `CMake` and in the `QtCreator` IDE with the `qmake`.
|
||||
|
||||
The `HelloWorld` example also expects the following [folders structure](building-tinyorm.mdx#folders-structure), let's create them.
|
||||
The `HelloWorld` example also expects the following [folders structure](building/tinyorm.mdx#folders-structure), let's create them.
|
||||
|
||||
<Tabs groupId={shell}>
|
||||
<TabItem value={pwsh} label={pwsh_label}>
|
||||
@@ -75,7 +76,7 @@ select * from posts;"
|
||||
|
||||
## Install dependencies
|
||||
|
||||
First, install the `vcpkg` package manager as is described [here](building-tinyorm.mdx#vcpkg).
|
||||
First, install the `vcpkg` package manager as is described [here](building/tinyorm.mdx#vcpkg).
|
||||
|
||||
The `range-v3` and `tabulate` libraries are required dependencies because `TinyORM` uses them in header files, you have to install them before you can use `TinyORM`. The `tabulate` library is only needed in the `tom` migrations it's used by the `migrate:status` command.
|
||||
|
||||
@@ -294,7 +295,7 @@ cmake --build . --target all
|
||||
|
||||
### Execute Hello world {#execute-hello-world-cmake}
|
||||
|
||||
Do not forget to add `TinyOrm0d.dll` on the path on Windows and on the `LD_LIBRARY_PATH` on Linux, so `HelloWorld` application can find it during execution, as is described [here](building-tinyorm.mdx#tinyorm-on-path-cmake).
|
||||
Do not forget to add `TinyOrm0d.dll` on the path on Windows and on the `LD_LIBRARY_PATH` on Linux, so `HelloWorld` application can find it during execution, as is described [here](building/tinyorm.mdx#tinyorm-on-path-cmake).
|
||||
|
||||
<Tabs groupId={shell} name='tinyorm-on-path'>
|
||||
<TabItem value={pwsh} label={pwsh_label}>
|
||||
@@ -309,7 +310,7 @@ Do not forget to add `TinyOrm0d.dll` on the path on Windows and on the `LD_LIBRA
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Create a symbolic link to the `HelloWorld.sqlite3` database inside the build folder. If you do not have enabled symbolic links without `Administrator` rights on your `Windows`, you can just simply copy the `HelloWorld.sqlite3` database or [`Allow symbolic links unprivileged`](building-tinyorm.mdx#allow-symbolic-links-unprivileged).
|
||||
Create a symbolic link to the `HelloWorld.sqlite3` database inside the build folder. If you do not have enabled symbolic links without `Administrator` rights on your `Windows`, you can just simply copy the `HelloWorld.sqlite3` database or [`Allow symbolic links unprivileged`](building/tinyorm.mdx#allow-symbolic-links-unprivileged).
|
||||
|
||||
<Tabs groupId={shell} name='tinyorm-on-path'>
|
||||
<TabItem value={pwsh} label={pwsh_label}>
|
||||
@@ -412,7 +413,7 @@ unix:!macx: \
|
||||
```
|
||||
|
||||
:::caution
|
||||
The exact [folders structure](building-tinyorm.mdx#folders-structure) is crucial in this example because the paths to the `TinyORM` source and build folders are relative.
|
||||
The exact [folders structure](building/tinyorm.mdx#folders-structure) is crucial in this example because the paths to the `TinyORM` source and build folders are relative.
|
||||
:::
|
||||
|
||||
:::tip
|
||||
@@ -440,21 +441,21 @@ Configuring with the `.qmake.conf` file has one big advantage that is that you d
|
||||
### Build Hello world {#build-hello-world-qmake}
|
||||
|
||||
:::tip
|
||||
I recommend creating a new `Session` in the `QtCreator IDE` as is described [here](building-tinyorm.mdx#open-qtcreator-ide).
|
||||
I recommend creating a new `Session` in the `QtCreator IDE` as is described [here](building/tinyorm.mdx#open-qtcreator-ide).
|
||||
:::
|
||||
|
||||
Now you can open the `HelloWorld.pro` project in the `QtCreator IDE`.
|
||||
|
||||
This will open the `Configure Project` tab, select some kit and update build folder paths to meet our [folders structure](building-tinyorm.mdx#folders-structure) or like you want.
|
||||
This will open the `Configure Project` tab, select some kit and update build folder paths to meet our [folders structure](building/tinyorm.mdx#folders-structure) or like you want.
|
||||
|
||||
<img src={require('./assets/img/building-hello-world/qmake-configure_project.png').default}
|
||||
<img src={require('./assets/img/hello-world/qmake-configure_project.png').default}
|
||||
alt='HelloWorld - QtCreator - Configure Project' width='760' />
|
||||
|
||||
You are ready to configure build options, hit <kbd>Ctrl</kbd>+<kbd>5</kbd> to open `Project Settings` tab and select `Build` in the left sidebar to open the `Build Settings`, it should look similar to the following picture.
|
||||
|
||||
Disable `QML debugging and profiling` and `Qt Quick Compiler`, they are not used.
|
||||
|
||||
<img src={require('./assets/img/building-hello-world/qmake-build_settings.png').default}
|
||||
<img src={require('./assets/img/hello-world/qmake-build_settings.png').default}
|
||||
className='no-blurry' alt='HelloWorld - QtCreator - Build Settings' width='760' />
|
||||
|
||||
Everything is ready to build, you can press <kbd>Ctrl</kbd>+<kbd>b</kbd> to build the project.
|
||||
@@ -465,7 +466,7 @@ The `QtCreator` takes care about all the necessary configuration, sets up the bu
|
||||
|
||||
Only one thing you might want to change is to run the `HelloWorld` example in the new terminal window. To do so, hit <kbd>Ctrl</kbd>+<kbd>5</kbd> to open the `Project Settings` tab and select `Run` in the left sidebar to open the `Run Settings`, then in the `Run` section select the `Run in terminal` checkbox.
|
||||
|
||||
Create a symbolic link to the `HelloWorld.sqlite3` database inside the build folder. If you do not have enabled symbolic links without `Administrator` rights on your `Windows`, you can just simply copy the `HelloWorld.sqlite3` database or [`Allow symbolic links unprivileged`](building-tinyorm.mdx#allow-symbolic-links-unprivileged).
|
||||
Create a symbolic link to the `HelloWorld.sqlite3` database inside the build folder. If you do not have enabled symbolic links without `Administrator` rights on your `Windows`, you can just simply copy the `HelloWorld.sqlite3` database or [`Allow symbolic links unprivileged`](building/tinyorm.mdx#allow-symbolic-links-unprivileged).
|
||||
|
||||
<Tabs groupId={shell} name='tinyorm-on-path'>
|
||||
<TabItem value={pwsh} label={pwsh_label}>
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
sidebar_position: 11
|
||||
sidebar_position: 3
|
||||
sidebar_label: Migrations
|
||||
description: How to compile the TinyORM migrations (tom) c++ console application on Windows and Linux.
|
||||
---
|
||||
|
||||
@@ -42,7 +43,7 @@ import {
|
||||
|
||||
We will try to create a working migrations console application called as <abbr title='TinyORM migrations'>`tom`</abbr> in the terminal with the `CMake` and in the `QtCreator` IDE with the `qmake`.
|
||||
|
||||
The `tom` console application also expects the following [folders structure](building-tinyorm.mdx#folders-structure), let's create them.
|
||||
The `tom` console application also expects the following [folders structure](building/tinyorm.mdx#folders-structure), let's create them.
|
||||
|
||||
<Tabs groupId={shell}>
|
||||
<TabItem value={pwsh} label={pwsh_label}>
|
||||
@@ -69,11 +70,11 @@ All these three console applications the `tom` example, `tom` migrations for uni
|
||||
|
||||
Working MySQL database server as the `tom` migrations currently provides support only for the MySQL database.
|
||||
|
||||
Install required dependencies and build the `TinyORM` library with the `tom` (it's enabled by default) as is described [here](building-hello-world.mdx#install-dependencies) and [here](building-tinyorm.mdx).
|
||||
Install required dependencies and build the `TinyORM` library with the `tom` (it's enabled by default) as is described [here](building/hello-world.mdx#install-dependencies) and [here](building/tinyorm.mdx).
|
||||
|
||||
### vcpkg.json manifest {#vcpkg-json-manifest}
|
||||
|
||||
Whole section about the `vcpkg` dependencies is described in the [Install dependencies](building-hello-world.mdx#install-dependencies).
|
||||
Whole section about the `vcpkg` dependencies is described in the [Install dependencies](building/hello-world.mdx#install-dependencies).
|
||||
|
||||
Create a `vcpkg.json` file with the following content. `CMake` example below uses this method.
|
||||
|
||||
@@ -201,7 +202,7 @@ And paste the following code.
|
||||
|
||||
### Migrations
|
||||
|
||||
If you have already built the `tom` application then you can generate a migrations using the [`make:migration`](migrations.mdx#generating-migrations) command 😎.
|
||||
If you have already built the `tom` application then you can generate a migrations using the [`make:migration`](database/migrations.mdx#generating-migrations) command 😎.
|
||||
|
||||
```bash
|
||||
tom make:migration create_posts_table
|
||||
@@ -278,7 +279,7 @@ If you want, you can also build the `tom` application without the migrations, si
|
||||
|
||||
### Seeders
|
||||
|
||||
If you have already built the `tom` application then you can generate a seeder using the [`make:seeder`](seeding.mdx#writing-seeders) command 😎.
|
||||
If you have already built the `tom` application then you can generate a seeder using the [`make:seeder`](database/seeding.mdx#writing-seeders) command 😎.
|
||||
|
||||
```bash
|
||||
tom make:seeder PostSeeder
|
||||
@@ -328,7 +329,7 @@ And paste the following code.
|
||||
} // namespace Seeders
|
||||
|
||||
:::tip
|
||||
You can create more seeder classes like this and use the `call<>()` method to invoke them as is described in the [Calling Additional Seeders](seeding.mdx#calling-additional-seeders) section.
|
||||
You can create more seeder classes like this and use the `call<>()` method to invoke them as is described in the [Calling Additional Seeders](database/seeding.mdx#calling-additional-seeders) section.
|
||||
:::
|
||||
|
||||
## Migrations with CMake
|
||||
@@ -529,7 +530,7 @@ target_link_libraries(\${Tom_target}
|
||||
|
||||
### Build migrations {#build-migrations-cmake}
|
||||
|
||||
Now you are ready to configure `tom` `CMake` application. Don't forget to prepare the build environment with the [`qtenv6.ps1`](building-tinyorm.mdx#windows-prerequisites) command if you are building with the `msvc`.
|
||||
Now you are ready to configure `tom` `CMake` application. Don't forget to prepare the build environment with the [`qtenv6.ps1`](building/tinyorm.mdx#windows-prerequisites) command if you are building with the `msvc`.
|
||||
|
||||
```bash
|
||||
cd ../tom-builds-cmake/build-debug
|
||||
@@ -568,7 +569,7 @@ cmake --build . --target all
|
||||
|
||||
### Execute migrations {#execute-migrations-cmake}
|
||||
|
||||
Do not forget to add `TinyOrm0d.dll` on the path on Windows and on the `LD_LIBRARY_PATH` on Linux, so `tom` application can find it during execution, as is described [here](building-tinyorm.mdx#tinyorm-on-path-cmake).
|
||||
Do not forget to add `TinyOrm0d.dll` on the path on Windows and on the `LD_LIBRARY_PATH` on Linux, so `tom` application can find it during execution, as is described [here](building/tinyorm.mdx#tinyorm-on-path-cmake).
|
||||
|
||||
<Tabs groupId={shell} name='tinyorm-on-path'>
|
||||
<TabItem value={pwsh} label={pwsh_label}>
|
||||
@@ -604,7 +605,7 @@ Execute `tom` application.
|
||||
|
||||
The output will look something like this.
|
||||
|
||||
<img src={require('./assets/img/building-migrations/tom_migrate_status.png').default}
|
||||
<img src={require('./assets/img/migrations/tom_migrate_status.png').default}
|
||||
alt='Tom migrations - migrate:status command output' width='660' />
|
||||
|
||||
See also the [final thoughts](#finish) on how to verify the `tom` executable file properties.
|
||||
@@ -676,7 +677,7 @@ unix:!macx: \
|
||||
```
|
||||
|
||||
:::caution
|
||||
The exact [folders structure](building-tinyorm.mdx#folders-structure) is crucial in this example because the paths to the `TinyORM` source and build folders are relative.
|
||||
The exact [folders structure](building/tinyorm.mdx#folders-structure) is crucial in this example because the paths to the `TinyORM` source and build folders are relative.
|
||||
:::
|
||||
|
||||
:::tip
|
||||
@@ -730,21 +731,21 @@ HEADERS += \
|
||||
### Build migrations {#build-migrations-qmake}
|
||||
|
||||
:::tip
|
||||
I recommend creating a new `Session` in the `QtCreator IDE` as is described [here](building-tinyorm.mdx#open-qtcreator-ide).
|
||||
I recommend creating a new `Session` in the `QtCreator IDE` as is described [here](building/tinyorm.mdx#open-qtcreator-ide).
|
||||
:::
|
||||
|
||||
Now you can open the `tom.pro` project in the `QtCreator IDE`.
|
||||
|
||||
This will open the `Configure Project` tab, select some kit and update build folder paths to meet our [folders structure](building-tinyorm.mdx#folders-structure) or like you want.
|
||||
This will open the `Configure Project` tab, select some kit and update build folder paths to meet our [folders structure](building/tinyorm.mdx#folders-structure) or like you want.
|
||||
|
||||
<img src={require('./assets/img/building-migrations/qmake-configure_project.png').default}
|
||||
<img src={require('./assets/img/migrations/qmake-configure_project.png').default}
|
||||
alt='tom - QtCreator - Configure Project' width='760' />
|
||||
|
||||
You are ready to configure build options, hit <kbd>Ctrl</kbd>+<kbd>5</kbd> to open `Project Settings` tab and select `Build` in the left sidebar to open the `Build Settings`, it should look similar to the following picture.
|
||||
|
||||
Disable `QML debugging and profiling` and `Qt Quick Compiler`, they are not used.
|
||||
|
||||
<img src={require('./assets/img/building-migrations/qmake-build_settings.png').default}
|
||||
<img src={require('./assets/img/migrations/qmake-build_settings.png').default}
|
||||
className='no-blurry' alt='tom - QtCreator - Build Settings' width='760' />
|
||||
|
||||
Everything is ready to build, you can press <kbd>Ctrl</kbd>+<kbd>b</kbd> to build the project.
|
||||
@@ -761,7 +762,7 @@ To execute the `tom` application press <kbd>Ctrl</kbd> + <kbd>r</kbd>.
|
||||
|
||||
The output will look something like this.
|
||||
|
||||
<img src={require('./assets/img/building-migrations/tom_migrate_status.png').default}
|
||||
<img src={require('./assets/img/migrations/tom_migrate_status.png').default}
|
||||
alt='Tom migrations - migrate:status command output' width='660' />
|
||||
|
||||
Happy migrating 🎉👌
|
||||
@@ -772,6 +773,6 @@ As the last thing, you can check that all the file properties were correctly set
|
||||
|
||||
Find the `tom.exe` file and press <kbd>Alt</kbd> + <kbd>Enter</kbd> to open the file properties. To check the executable manifest you can use eg. the [Resource Hacker](http://www.angusj.com/resourcehacker/).
|
||||
|
||||
<img src={require('./assets/img/building-migrations/tom_file_properties.png').default}
|
||||
<img src={require('./assets/img/migrations/tom_file_properties.png').default}
|
||||
alt='tom.exe file properties detail' width='440' />
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
sidebar_position: 9
|
||||
sidebar_position: 0
|
||||
sidebar_label: TinyORM
|
||||
hide_table_of_contents: true
|
||||
description: How to compile the TinyORM c++ library on Windows and Linux.
|
||||
---
|
||||
@@ -90,7 +91,7 @@ Open `Local Security Policy`, go to `Local Policies - User Rights Assignment`, o
|
||||
|
||||
## Folders structure
|
||||
|
||||
All `tinyorm.org` examples are based on the following folders structure. The `tom` folder will contain a [migrations console application](building-migrations.mdx).
|
||||
All `tinyorm.org` examples are based on the following folders structure. The `tom` folder will contain a [migrations console application](building/migrations.mdx).
|
||||
|
||||
<Tabs groupId={shell}>
|
||||
<TabItem value={pwsh} label={pwsh_label} className='tiny-tree'>
|
||||
@@ -471,7 +472,7 @@ As the last thing, do not forget to add `TinyOrm0d.dll` on the path on Windows a
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Now you can try the [`HelloWorld CMake`](building-hello-world.mdx#hello-world-with-cmake) example.
|
||||
Now you can try the [`HelloWorld CMake`](building/hello-world.mdx#hello-world-with-cmake) example.
|
||||
|
||||
## Building with qmake
|
||||
|
||||
@@ -548,19 +549,19 @@ Now you can open the `TinyOrm.pro` project in the `QtCreator IDE`.
|
||||
|
||||
This will open the `Configure Project` tab, select some kit and update build folder paths to meet our [folders structure](#folders-structure) or like you want.
|
||||
|
||||
<img src={require('./assets/img/building-tinyorm/qmake-configure_project.png').default}
|
||||
<img src={require('./assets/img/tinyorm/qmake-configure_project.png').default}
|
||||
alt='TinyORM - QtCreator - Configure Project' width='760' />
|
||||
|
||||
You are ready to configure build options, hit <kbd>Ctrl</kbd>+<kbd>5</kbd> to open `Project Settings` tab and select `Build` in the left sidebar to open the `Build Settings`, it should look similar to the following picture.
|
||||
|
||||
Disable `QML debugging and profiling` and `Qt Quick Compiler`, they are not used.
|
||||
|
||||
<img src={require('./assets/img/building-tinyorm/qmake-build_settings.png').default}
|
||||
<img src={require('./assets/img/tinyorm/qmake-build_settings.png').default}
|
||||
alt='TinyORM - QtCreator - Build Settings' width='760' />
|
||||
|
||||
If you want to change some `TinyORM` build options, you can pass them to the `Build Steps` - `qmake TinyOrm.pro` - `Additional arguments` input field. It can look like this.
|
||||
|
||||
<img src={require('./assets/img/building-tinyorm/qmake-additional_arguments.png').default}
|
||||
<img src={require('./assets/img/tinyorm/qmake-additional_arguments.png').default}
|
||||
alt='TinyORM - QtCreator - Build Settings - Additional arguments' width='660' />
|
||||
|
||||
#### Build TinyORM
|
||||
2
docs/database/_category_.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
position: 3
|
||||
label: '✨ Database'
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
sidebar_position: 3
|
||||
sidebar_position: 0
|
||||
sidebar_label: Getting Started
|
||||
description: TinyORM makes interacting with a database extremely simple using raw SQL, a fluent query builder, and the TinyORM. It provides first-party support for three databases MySQL/MariaDB, PostgreSQL, and SQLite.
|
||||
---
|
||||
|
||||
@@ -13,7 +14,7 @@ description: TinyORM makes interacting with a database extremely simple using ra
|
||||
|
||||
## Introduction
|
||||
|
||||
Almost every modern application interacts with a database. TinyORM makes interacting with a database extremely simple using raw SQL, a [fluent query builder](query-builder.mdx), and the [TinyORM](tinyorm.mdx). Currently, TinyORM provides first-party support for three databases:
|
||||
Almost every modern application interacts with a database. TinyORM makes interacting with a database extremely simple using raw SQL, a [fluent query builder](database/query-builder.mdx), and the [TinyORM](tinyorm/getting-started.mdx). Currently, TinyORM provides first-party support for three databases:
|
||||
|
||||
- MySQL or MariaDB 5.0+ ([Version Policy](https://en.wikipedia.org/wiki/MySQL#Release_history))
|
||||
- PostgreSQL 9.6+ ([Version Policy](https://www.postgresql.org/support/versioning/))
|
||||
@@ -59,7 +60,7 @@ A database connection is resolved lazily, which means that the connection config
|
||||
:::
|
||||
|
||||
:::tip
|
||||
You can also use predefined string constants to avoid unnecessary `QString` instantiations, as used in the `tom` migrations [example](building-migrations.mdx#string-constants-example).
|
||||
You can also use predefined string constants to avoid unnecessary `QString` instantiations, as used in the `tom` migrations [example](building/migrations.mdx#string-constants-example).
|
||||
:::
|
||||
|
||||
#### SQLite Configuration
|
||||
@@ -232,5 +233,5 @@ All transaction methods accept a connection name as the optional argument:
|
||||
DB::beginTransaction("mysql_test");
|
||||
|
||||
:::tip
|
||||
The `DB` facade's transaction methods control the transactions for both the [query builder](query-builder.mdx) and [TinyORM](tinyorm.mdx).
|
||||
The `DB` facade's transaction methods control the transactions for both the [query builder](database/query-builder.mdx) and [TinyORM](tinyorm/getting-started.mdx).
|
||||
:::
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
sidebar_position: 5
|
||||
sidebar_position: 2
|
||||
sidebar_label: Migrations
|
||||
description: Migrations are like version control for your database, allowing your team to define and share the application's database schema definition. Migrations use the Schema facade that provides database agnostic support for creating and manipulating tables across all of TinyORM's supported database systems.
|
||||
---
|
||||
|
||||
@@ -820,7 +821,7 @@ Support for default expressions depends on your database driver, database versio
|
||||
:::
|
||||
|
||||
:::tip
|
||||
You can obtain an `Orm::Query::Expression` using the [`DB::raw`](query-builder.mdx#raw-expressions) method if you have access to the `DB` facade.
|
||||
You can obtain an `Orm::Query::Expression` using the [`DB::raw`](database/query-builder.mdx#raw-expressions) method if you have access to the `DB` facade.
|
||||
:::
|
||||
|
||||
#### Column Order
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
sidebar_position: 4
|
||||
sidebar_position: 1
|
||||
sidebar_label: Query Builder
|
||||
description: TinyORM's database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database operations in your application. The query builder uses QSqlQuery parameter binding to protect your application against SQL injection attacks. There is no need to clean or sanitize strings passed to the query builder as query bindings.
|
||||
---
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
sidebar_position: 6
|
||||
sidebar_position: 3
|
||||
sidebar_label: Seeding
|
||||
description: TinyORM includes the ability to seed your database with data using seed classes. The DatabaseSeeder class is considered as the root seeder. From this class, you may use the `call` method to run other seed classes, allowing you to control the seeding order.
|
||||
---
|
||||
|
||||
@@ -15,7 +16,7 @@ description: TinyORM includes the ability to seed your database with data using
|
||||
TinyORM includes the ability to seed your database with data using seed classes. All seed classes should be stored in the `database/seeders` directory. The `DatabaseSeeder` class is considered as the root seeder. From this class, you may use the `call` method to run other seed classes, allowing you to control the seeding order.
|
||||
|
||||
:::tip
|
||||
[Mass assignment protection](tinyorm.mdx#mass-assignment) is automatically disabled during database seeding.
|
||||
[Mass assignment protection](tinyorm/getting-started.mdx#mass-assignment) is automatically disabled during database seeding.
|
||||
:::
|
||||
|
||||
## Writing Seeders
|
||||
@@ -30,7 +31,7 @@ tom make:seeder UserSeeder
|
||||
You can omit the `Seeder` word in the class name, `tom` appends it for you.
|
||||
:::
|
||||
|
||||
A seeder class only contains one method by default: `run`. This method is called when the `db:seed` tom command is executed. Within the `run` method, you may insert data into your database however you wish. You may use the [query builder](query-builder.mdx#insert-statements) to manually insert data.
|
||||
A seeder class only contains one method by default: `run`. This method is called when the `db:seed` tom command is executed. Within the `run` method, you may insert data into your database however you wish. You may use the [query builder](database/query-builder.mdx#insert-statements) to manually insert data.
|
||||
|
||||
As an example, let's modify the default `DatabaseSeeder` class and add a database insert statement to the `run` method:
|
||||
|
||||
@@ -58,7 +59,7 @@ As an example, let's modify the default `DatabaseSeeder` class and add a databas
|
||||
} // namespace Seeders
|
||||
|
||||
:::tip
|
||||
The multi-insert [`insert`](query-builder.mdx#multi-insert-overload) method overload is ideal for seeding data.
|
||||
The multi-insert [`insert`](database/query-builder.mdx#multi-insert-overload) method overload is ideal for seeding data.
|
||||
:::
|
||||
|
||||
### Calling Additional Seeders
|
||||
@@ -124,7 +125,7 @@ tom migrate:fresh --seed
|
||||
```
|
||||
|
||||
:::tip
|
||||
You can change the default seeders path as is described in the [`C preprocessor macros`](building-tinyorm.mdx#TINYTOM_SEEDERS_DIR), CMake provides the [`TOM_SEEDERS_DIR`](building-tinyorm.mdx#TOM_SEEDERS_DIR) option.
|
||||
You can change the default seeders path as is described in the [`C preprocessor macros`](building/tinyorm.mdx#TINYTOM_SEEDERS_DIR), CMake provides the [`TOM_SEEDERS_DIR`](building/tinyorm.mdx#TOM_SEEDERS_DIR) option.
|
||||
:::
|
||||
|
||||
#### Forcing Seeders To Run In Production
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
sidebar_label: 🔧 Dependencies
|
||||
hide_table_of_contents: true
|
||||
description: Library dependencies are MySQL Connector/C 8, range-v3 0.11.0, tabulate and the Qt framework version used during development was 5.15.2 and >= 6.2. The code was developed on MSVC 16.9-16.11.15, GCC 10.2-11.3, and Clang 11-14.
|
||||
---
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
sidebar_label: 🚀 Supported Compilers
|
||||
hide_table_of_contents: true
|
||||
description: Platform requirements and supported compilers for TinyORM c++ library.
|
||||
---
|
||||
|
||||
2
docs/tinyorm/_category_.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
position: 4
|
||||
label: '🎉 TinyORM'
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
sidebar_position: 7
|
||||
sidebar_position: 0
|
||||
sidebar_label: Getting Started
|
||||
description: TinyORM is an object-relational mapper (ORM) that makes it enjoyable to interact with your database. When using TinyORM, each database table has a corresponding "Model" that is used to interact with that table. In addition to retrieving records from the database table, TinyORM models allow you to insert, update, and delete records from the table as well.
|
||||
---
|
||||
|
||||
@@ -30,7 +31,7 @@ description: TinyORM is an object-relational mapper (ORM) that makes it enjoyabl
|
||||
TinyORM is an object-relational mapper (ORM) that makes it enjoyable to interact with your database. When using TinyORM, each database table has a corresponding "Model" that is used to interact with that table. In addition to retrieving records from the database table, TinyORM models allow you to insert, update, and delete records from the table as well.
|
||||
|
||||
:::note
|
||||
Before getting started, be sure to configure a database connection in your application. For more information on configuring your database, check out [the database configuration documentation](database.mdx#configuration).
|
||||
Before getting started, be sure to configure a database connection in your application. For more information on configuring your database, check out [the database configuration documentation](database/getting-started.mdx#configuration).
|
||||
:::
|
||||
|
||||
## TinyORM Model Conventions
|
||||
@@ -225,7 +226,7 @@ By default, a newly instantiated model instance will not contain any attribute v
|
||||
|
||||
## Retrieving Models
|
||||
|
||||
Once you have created a model and its associated database table, you are ready to start retrieving data from your database. You can think of each TinyOrm model as a powerful [query builder](query-builder.mdx) allowing you to fluently query the database table associated with the model. The model's `all` method will retrieve all of the records from the model's associated database table:
|
||||
Once you have created a model and its associated database table, you are ready to start retrieving data from your database. You can think of each TinyOrm model as a powerful [query builder](database/query-builder.mdx) allowing you to fluently query the database table associated with the model. The model's `all` method will retrieve all of the records from the model's associated database table:
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@@ -236,7 +237,7 @@ Once you have created a model and its associated database table, you are ready t
|
||||
|
||||
#### Building Queries
|
||||
|
||||
The TinyOrm `all` method will return all of the results in the model's table. However, since each TinyOrm model serves as a [query builder](query-builder.mdx), you may add additional constraints to queries and then invoke the `get` method to retrieve the results:
|
||||
The TinyOrm `all` method will return all of the results in the model's table. However, since each TinyOrm model serves as a [query builder](database/query-builder.mdx), you may add additional constraints to queries and then invoke the `get` method to retrieve the results:
|
||||
|
||||
auto flights = Flight::whereEq("active", 1)
|
||||
->orderBy("name")
|
||||
@@ -244,7 +245,7 @@ The TinyOrm `all` method will return all of the results in the model's table. Ho
|
||||
.get();
|
||||
|
||||
:::tip
|
||||
Since TinyOrm models are query builders, you should review all of the methods provided by TinyORM's [query builder](query-builder.mdx). You may use any of these methods when writing your TinyOrm queries.
|
||||
Since TinyOrm models are query builders, you should review all of the methods provided by TinyORM's [query builder](database/query-builder.mdx). You may use any of these methods when writing your TinyOrm queries.
|
||||
:::
|
||||
|
||||
:::note
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
sidebar_position: 8
|
||||
sidebar_position: 1
|
||||
sidebar_label: Relationships
|
||||
description: TinyORM relationships are defined as methods on your TinyORM model classes. Since relationships also serve as powerful query builders, defining relationships as methods provides powerful method chaining and querying capabilities.
|
||||
---
|
||||
|
||||
@@ -38,7 +39,7 @@ Database tables are often related to one another. For example, a blog post may h
|
||||
|
||||
## Defining Relationships
|
||||
|
||||
TinyORM relationships are defined as methods on your TinyORM model classes. Since relationships also serve as powerful [query builders](query-builder.mdx), defining relationships as methods provides powerful method chaining and querying capabilities. For example, we may chain additional query constraints on this `posts` relationship:
|
||||
TinyORM relationships are defined as methods on your TinyORM model classes. Since relationships also serve as powerful [query builders](database/query-builder.mdx), defining relationships as methods provides powerful method chaining and querying capabilities. For example, we may chain additional query constraints on this `posts` relationship:
|
||||
|
||||
user->posts()->whereEq("active", 1).get();
|
||||
|
||||
@@ -261,7 +262,7 @@ Once the relationship method has been defined, we can access the `QVector<Relate
|
||||
//
|
||||
}
|
||||
|
||||
Since all relationships also serve as [query builders](query-builder.mdx), you may add further constraints to the relationship query by calling the `comments` method and continuing to chain conditions onto the query, all the `TinyBuilder` methods which are related to building queries are proxied:
|
||||
Since all relationships also serve as [query builders](database/query-builder.mdx), you may add further constraints to the relationship query by calling the `comments` method and continuing to chain conditions onto the query, all the `TinyBuilder` methods which are related to building queries are proxied:
|
||||
|
||||
auto comment = Post::find(1)->comments()
|
||||
->whereEq("title", "foo")
|
||||
@@ -703,7 +704,7 @@ If you have defined a many-to-many relationship that uses a custom pivot model,
|
||||
|
||||
## Querying Relations
|
||||
|
||||
Since all TinyORM relationships are defined via methods, you may call those methods to obtain an instance of the relationship without actually executing a query to load the related models. In addition, all types of TinyORM relationships also serve as [query builders](query-builder.mdx), allowing you to continue to chain constraints onto the relationship query before finally executing the SQL query against your database.
|
||||
Since all TinyORM relationships are defined via methods, you may call those methods to obtain an instance of the relationship without actually executing a query to load the related models. In addition, all types of TinyORM relationships also serve as [query builders](database/query-builder.mdx), allowing you to continue to chain constraints onto the relationship query before finally executing the SQL query against your database.
|
||||
|
||||
For example, imagine a blog application in which a `User` model has many associated `Post` models:
|
||||
|
||||
@@ -740,7 +741,7 @@ You may query the `posts` relationship and add additional constraints to the rel
|
||||
|
||||
user->posts()->whereEq("active", 1).get();
|
||||
|
||||
You are able to use any of the TinyORM [query builder's](query-builder.mdx) methods on the relationship, so be sure to explore the query builder documentation to learn about all of the methods that are available to you.
|
||||
You are able to use any of the TinyORM [query builder's](database/query-builder.mdx) methods on the relationship, so be sure to explore the query builder documentation to learn about all of the methods that are available to you.
|
||||
|
||||
:::note
|
||||
All the `TinyBuilder` methods which are related to building queries are proxied on the `Relation` base class.
|
||||
@@ -763,7 +764,7 @@ from posts
|
||||
where user_id = ? and active = 1 or votes >= 100
|
||||
```
|
||||
|
||||
In most situations, you should use [logical groups](query-builder.mdx#logical-grouping) to group the conditional checks between parentheses:
|
||||
In most situations, you should use [logical groups](database/query-builder.mdx#logical-grouping) to group the conditional checks between parentheses:
|
||||
|
||||
user->posts()
|
||||
->where([](auto &query)
|
||||
@@ -1019,7 +1020,7 @@ Sometimes you may wish to eager load a relationship but also specify additional
|
||||
query.where("title", "like", "%code%");
|
||||
}}})->get();
|
||||
|
||||
In this example, TinyORM will only eager load posts where the post's `title` column contains the word `code`. You may call other [query builder](query-builder.mdx) methods to further customize the eager loading operation:
|
||||
In this example, TinyORM will only eager load posts where the post's `title` column contains the word `code`. You may call other [query builder](database/query-builder.mdx) methods to further customize the eager loading operation:
|
||||
|
||||
auto users = User::with({{"posts", [](auto &query)
|
||||
{
|
||||
@@ -1169,10 +1170,10 @@ The many-to-many relationship also supports the `create` and `createMany` method
|
||||
{{"active", false}},
|
||||
});
|
||||
|
||||
You may also use the `findOrNew`, `firstOrNew`, `firstOrCreate`, and `updateOrCreate` methods to [create and update models on relationships](tinyorm.mdx#retrieving-or-creating-models).
|
||||
You may also use the `findOrNew`, `firstOrNew`, `firstOrCreate`, and `updateOrCreate` methods to [create and update models on relationships](tinyorm/getting-started.mdx#retrieving-or-creating-models).
|
||||
|
||||
:::tip
|
||||
Before using the `create` method, be sure to review the [mass assignment](tinyorm.mdx#mass-assignment) documentation.
|
||||
Before using the `create` method, be sure to review the [mass assignment](tinyorm/getting-started.mdx#mass-assignment) documentation.
|
||||
:::
|
||||
|
||||
### Belongs To Relationships {#updating-belongs-to-relationships}
|
||||