mirror of
https://github.com/silverqx/TinyORM.git
synced 2026-05-13 04:48:57 -05:00
docs use make:seeder to generate seeders
This commit is contained in:
@@ -276,6 +276,12 @@ 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 😎.
|
||||
|
||||
```bash
|
||||
tom make:seeder PostSeeder
|
||||
```
|
||||
|
||||
The expected folders structure is described a few paragraphs [above](#folders-structure). The [`seeders.pri`](#seeders-source-files) file is used only by the `qmake` build system and is not needed with `CMake` builds.
|
||||
|
||||
Let's create the root seeder class manually.
|
||||
|
||||
@@ -20,6 +20,16 @@ TinyORM includes the ability to seed your database with data using seed classes.
|
||||
|
||||
## Writing Seeders
|
||||
|
||||
To generate a seeder, execute the `make:seeder` `tom` command. A new seeder will be placed in the `database/seeders` directory relative to the current <abbr title='Current working directory'>pwd</abbr>:
|
||||
|
||||
```bash
|
||||
tom make:seeder UserSeeder
|
||||
```
|
||||
|
||||
:::tip
|
||||
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.
|
||||
|
||||
As an example, let's modify the default `DatabaseSeeder` class and add a database insert statement to the `run` method:
|
||||
|
||||
Reference in New Issue
Block a user