Skip to content

Commit

Permalink
docs: extended seeding configuration section on defining paths
Browse files Browse the repository at this point in the history
  • Loading branch information
tada5hi committed Feb 14, 2023
1 parent 5d092ad commit 5d7b486
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
22 changes: 13 additions & 9 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -258,20 +258,24 @@ Seeding the database is fairly easy and can be achieved by following the steps b

#### Configuration

Seeder paths are configured as **glob patterns**, making it easy
to match all the factory/seeder files in your project without configuration effort:
- use `*` to match anything expect slashes and hidden files
- use `**` to match zero or more directories
- use comma separate values between `{}` to match against a list of options

Check out the [glob](https://www.npmjs.com/package/glob) documentation for other supported pattern features.
It is important to use the posix/unix path separator (/) because
the Windows path separator (\\) is used to match paths with literal global pattern characters.

The seeder- & factory-location, can be specified via:
- `environment` variable(s)
- extended `data-source.ts` file
- `runSeeder(s)` method options parameter, in case of a direct code base usage

> The default factory path is: `src/database/factories/**/*{.ts,.js}`
> The default seed path is: `src/database/seeds/**/*{.ts,.js}`
`env`
```
TYPEORM_SEEDING_FACTORIES=src/database/factories/**/*{.ts,.js}
TYPEORM_SEEDING_SEEDS=src/database/seeds/**/*{.ts,.js}
```
The following values are assumed by default:
- factory path: `src/database/factories/**/*{.ts,.js}`
- seed path: `src/database/seeds/**/*{.ts,.js}`

`data-source.ts`

Expand Down
16 changes: 13 additions & 3 deletions docs/guide/seeding.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@ Seeding the database is fairly easy and can be achieved by following the steps b

## Configuration

Seeder paths are configured as **glob patterns**, making it easy
to match all the factory/seeder files in your project without configuration effort:
- use `*` to match anything expect slashes and hidden files
- use `**` to match zero or more directories
- use comma separate values between `{}` to match against a list of options

Check out the [glob](https://www.npmjs.com/package/glob) documentation for other supported pattern features.
It is important to use the posix/unix path separator (/) because
the Windows path separator (\\) is used to match paths with literal global pattern characters.

The seeder- & factory-location, can be specified via:
- `environment` variable(s)
- extended `data-source.ts` file
- `runSeeder(s)` method options parameter, in case of a direct code base usage

> The default factory path is: `src/database/factories/**/*{.ts,.js}`
> The default seed path is: `src/database/seeds/**/*{.ts,.js}`
The following values are assumed by default:
- factory path: `src/database/factories/**/*{.ts,.js}`
- seed path: `src/database/seeds/**/*{.ts,.js}`

`env`
```
Expand Down

0 comments on commit 5d7b486

Please sign in to comment.