{"_id":"@acore/typeorm-seeding","_rev":"2-8146ed5ec6f95a88b0e122884fa6de43","name":"@acore/typeorm-seeding","dist-tags":{"latest":"1.6.2"},"versions":{"1.6.1":{"name":"@acore/typeorm-seeding","version":"1.6.1","description":"🌱 A delightful way to seed test data into your database.","license":"MIT","author":{"name":"Gery Hirschfeld","email":"gery.hirschfeld@w3tec.ch","url":"https://github.com/hirsch88"},"main":"dist/typeorm-seeding.js","types":"dist/typeorm-seeding.d.ts","bin":{"typeorm-seeding":"dist/cli.js"},"repository":{"type":"git","url":"git+https://github.com/w3tecch/typeorm-seeding.git"},"scripts":{"prebuild":"rimraf dist","format":"prettier --write \"src/**/*.ts\"","lint":"eslint \"src/**/*.ts\" --fix","build":"npm run prebuild && tsc --project ./tsconfig.build.json","watch":"rollup -cw","test":"jest","test:watch":"jest --watch","test:cov":"jest --coverage","semantic-release":"semantic-release","schema:drop":"ts-node ./node_modules/typeorm/cli.js schema:drop -c sample","schema:sync":"ts-node ./node_modules/typeorm/cli.js schema:sync -c sample","schema:log":"ts-node ./node_modules/typeorm/cli.js schema:log -c sample","seed:run":"ts-node ./dist/cli.js seed -c sample","seed:config":"ts-node ./dist/cli.js config -c sample"},"devDependencies":{"@semantic-release/git":"^9.0.0","@types/bcryptjs":"^2.4.2","@types/chalk":"^2.2.0","@types/faker":"^5.5.0","@types/glob":"7.1.1","@types/jest":"^25.2.1","@types/node":"13.11.1","@types/yargs":"^15.0.4","@typescript-eslint/eslint-plugin":"^2.27.0","@typescript-eslint/parser":"^2.27.0","bcryptjs":"^2.4.3","eslint":"^6.8.0","eslint-config-prettier":"^6.10.1","eslint-plugin-import":"^2.20.2","jest":"^25.3.0","prettier":"^2.0.4","rimraf":"^3.0.2","semantic-release":"^17.0.4","sqlite":"^4.0.6","sqlite3":"^4.1.1","ts-jest":"^25.3.1","typeorm":"^0.2.24","typescript":"^3.8.3"},"dependencies":{"chalk":"^4.0.0","faker":"5.5.2","glob":"7.1.6","ora":"4.0.3","reflect-metadata":"0.1.13","yargs":"15.3.1"},"peerDependencies":{"typeorm":"^0.2.24"},"resolutions":{"mem":">=4.0.0"},"gitHead":"07e73cf706ae2c2cf495bb0dc1a2c1513f245a02","bugs":{"url":"https://github.com/w3tecch/typeorm-seeding/issues"},"homepage":"https://github.com/w3tecch/typeorm-seeding#readme","_id":"@acore/typeorm-seeding@1.6.1","_nodeVersion":"12.18.4","_npmVersion":"7.7.0","dist":{"integrity":"sha512-GbpAVLGfOWcIvMKpW0oUcuQY7NHyaPMmNCi6zGUY8/+GE0Xd0P2Fm3CEkuSRlot8Pkku0gZzJ/hYYVJQPZVSxA==","shasum":"5422bdbeda1064de3b3187c327eff6404c28700e","tarball":"https://registry.npmjs.org/@acore/typeorm-seeding/-/typeorm-seeding-1.6.1.tgz","fileCount":4,"unpackedSize":16451,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgr4t/CRA9TVsSAnZWagAANSYQAI1QhYGxe9KV6yID1w6I\nAsga1/VaL4i25zfrRGjrQFlq6NTHz9Z/0WvhQA0DG7HhK5T6oZO+SsvCrTdq\nWCGwD9gZuFkKZEeBmX3QL3jQNGvdhpuViFcvhet1QN+0D3SwKt2iru0Vpia2\nlD8rm0Vs+Q1ABB3g5Xv9nUKsM+mx04oDN5TDN/CGNKH9MjmdS3U2k6ST1sEW\nZVBQwoL/zd1X64sECSOKHtqLRmfbiMZGFTKExam6zD18MQ38M3MP+z9efaUk\nlcKlRCM0eiieddh3ffOvgwuGq9KENm+tY08IsAneF5HMTV9DYJIyNHAphtsV\nTAEsd8iIz93jLEMY/Dou7mQFUWHWELRA9I1oV0Zzz9o50KBeIW76XGS/2siR\ntQFqwjMFS7qaiCN0ETUUydt1Gq+q+gZKkfRTnmHcxH3+U1LHZycIdLoQh2y6\n+OGuEFNJ1+EMQhgCjGgkV9JIIdycnUE65Bytnj2yUwrQ3Dx9exdQM0hB+9uK\nLkAwxI2spk0oqRxg83TPqQ33pm+ilNsNOxIJ30+U2SyjdGhteRaLDz+hz9xq\nQPlcq1dEeYmtaLQFiz9UsKVdZSpk+uVtxjI5BJuclRxAU8h83qy7VWFAp1eH\nK/qmNKQGqTm3wXAB/zRRM28cZjD79J4P2421CRUhyxwnwd9q3Rm7b9WP9uhV\n3LGl\r\n=lEv0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICeuOAXyqIbbOwNBMrK9erku/hPKowUBhF5MvGdUpOZDAiBPoma1PK0At999Tey8w//yyBtSg9n39WXBtM7Z52UeBA=="}]},"_npmUser":{"name":"saeldur","email":"joerivanvuuren@gmail.com"},"directories":{},"maintainers":[{"name":"saeldur","email":"joerivanvuuren@gmail.com"},{"name":"yehonal","email":"yehonal.azeroth@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/typeorm-seeding_1.6.1_1622117247197_0.3442229048462153"},"_hasShrinkwrap":false},"1.6.2":{"name":"@acore/typeorm-seeding","version":"1.6.2","description":"🌱 A delightful way to seed test data into your database.","license":"MIT","author":{"name":"Gery Hirschfeld","email":"gery.hirschfeld@w3tec.ch","url":"https://github.com/hirsch88"},"main":"dist/typeorm-seeding.js","types":"dist/typeorm-seeding.d.ts","bin":{"typeorm-seeding":"dist/cli.js"},"repository":{"type":"git","url":"git+https://github.com/w3tecch/typeorm-seeding.git"},"scripts":{"prebuild":"rimraf dist","format":"prettier --write \"src/**/*.ts\"","lint":"eslint \"src/**/*.ts\" --fix","build":"npm run prebuild && tsc --project ./tsconfig.build.json","watch":"rollup -cw","test":"jest","test:watch":"jest --watch","test:cov":"jest --coverage","semantic-release":"semantic-release","schema:drop":"ts-node ./node_modules/typeorm/cli.js schema:drop -c sample","schema:sync":"ts-node ./node_modules/typeorm/cli.js schema:sync -c sample","schema:log":"ts-node ./node_modules/typeorm/cli.js schema:log -c sample","seed:run":"ts-node ./dist/cli.js seed -c sample","seed:config":"ts-node ./dist/cli.js config -c sample"},"devDependencies":{"@semantic-release/git":"^9.0.0","@types/bcryptjs":"^2.4.2","@types/chalk":"^2.2.0","@types/faker":"^5.5.0","@types/glob":"7.1.1","@types/jest":"^25.2.1","@types/node":"13.11.1","@types/yargs":"^15.0.4","@typescript-eslint/eslint-plugin":"^2.27.0","@typescript-eslint/parser":"^2.27.0","bcryptjs":"^2.4.3","eslint":"^6.8.0","eslint-config-prettier":"^6.10.1","eslint-plugin-import":"^2.20.2","jest":"^25.3.0","prettier":"^2.0.4","rimraf":"^3.0.2","semantic-release":"^17.0.4","sqlite":"^4.0.6","sqlite3":"^4.1.1","ts-jest":"^25.3.1","typeorm":"^0.2.24","typescript":"^3.8.3"},"dependencies":{"chalk":"^4.0.0","faker":"5.5.2","glob":"7.1.6","ora":"4.0.3","reflect-metadata":"0.1.13","yargs":"15.3.1"},"peerDependencies":{"typeorm":"^0.2.24"},"resolutions":{"mem":">=4.0.0"},"gitHead":"07e73cf706ae2c2cf495bb0dc1a2c1513f245a02","bugs":{"url":"https://github.com/w3tecch/typeorm-seeding/issues"},"homepage":"https://github.com/w3tecch/typeorm-seeding#readme","_id":"@acore/typeorm-seeding@1.6.2","_nodeVersion":"12.18.4","_npmVersion":"7.7.0","dist":{"integrity":"sha512-zbIDdcURCZNX5PUZw/AK1AqCNTypEqSBI5NmflmgQfepoWJSiHGrKoDTPy8Rn/akOKfNGYsqvkFDsauVBwRq7Q==","shasum":"bd7c997b3cf8adccc1a0d1d899de6cd38e851707","tarball":"https://registry.npmjs.org/@acore/typeorm-seeding/-/typeorm-seeding-1.6.2.tgz","fileCount":40,"unpackedSize":73370,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgr50FCRA9TVsSAnZWagAAL7gP/1sNJXPd/uSEsTV5PqVe\n76i4YUDdK+P/pAt6CyG2xtRlHOd5Ljm62vUOz1syNI8YJHZB/k7xMHaRhQLJ\nuxs0wUCCbaOXzRiuBNu0AWBUJAvwgiSd8phGVIyrPpJGS2bTm2cGQSRT9Ugb\nAPnGFUv9upEGA+9tUi45HbjIBbU3AJmJYaf0hTKgl9vnTMd2oumCN6prUrSt\nnpd+fcKoMYVbBvzpp9DZnszMJ03YKvwqrl8a0YPmpHQuqImQKl89SHL2IyHE\nVRrU4+1N1ATlNI7wev+ij6ckW6AARgH2NIfTSvCkb78CKxJUWisnhWNmPLWC\n1l6AG1mmmJs+oGspG3r5hyoI2lcUj5XqhsjoRkkLgDYiNkEyvriu1kL6SzvB\nBh6gVV/lt/TILjsMRuLbpbI+p7u8Vb0cL4aPakZoRRIyhIaWkNqvhDBHObIG\nO1LOMz/2VBIMmdh5J3qPDkcFtTqMunWYHJgO3Ve0HuFKJ5MLtgogEWeFzNh0\ncz9kIny3wDIpa/nVRvCHOz/u4tAdxlYrP7DAb9aNC/TClnfettrGsmfxwJXA\ndHv7KFwOMnKZaLFumYYJr3zeVTtpJlJChHhDSrFlvgnrpcFIQ0iPX9tLrZrk\nGenhmbHksdeuf+TKiOrzSFrAq1QJ9tH5jMyeapXS3syeT27TuaKMqAh8Y2TX\nWm1q\r\n=OrBw\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEJQDCDMQsVKyiyoJNME6NN0KXdW33fWKJPZtDRqLHtYAiEAnfhgxQ4IIDCJxrMyuhWOs7IXd0Xt1V8nLGPUyat8+PY="}]},"_npmUser":{"name":"saeldur","email":"joerivanvuuren@gmail.com"},"directories":{},"maintainers":[{"name":"saeldur","email":"joerivanvuuren@gmail.com"},{"name":"yehonal","email":"yehonal.azeroth@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/typeorm-seeding_1.6.2_1622121732871_0.3974071626859499"},"_hasShrinkwrap":false}},"time":{"created":"2021-05-27T12:07:26.855Z","1.6.1":"2021-05-27T12:07:27.310Z","modified":"2022-04-04T11:12:48.005Z","1.6.2":"2021-05-27T13:22:13.041Z"},"maintainers":[{"name":"saeldur","email":"joerivanvuuren@gmail.com"},{"name":"yehonal","email":"yehonal.azeroth@gmail.com"}],"description":"🌱 A delightful way to seed test data into your database.","homepage":"https://github.com/w3tecch/typeorm-seeding#readme","repository":{"type":"git","url":"git+https://github.com/w3tecch/typeorm-seeding.git"},"author":{"name":"Gery Hirschfeld","email":"gery.hirschfeld@w3tec.ch","url":"https://github.com/hirsch88"},"bugs":{"url":"https://github.com/w3tecch/typeorm-seeding/issues"},"license":"MIT","readme":"<p align=\"center\">\n  <img src=\"./logo.png\" alt=\"logo\" width=\"160\" />\n</p>\n\n<h1 align=\"center\" style=\"text-align: center;\">TypeORM Seeding</h1>\n\n<p align=\"center\">\n  <a href=\"https://www.npmjs.com/package/typeorm-seeding\">\n    <img src=\"https://img.shields.io/npm/v/typeorm-seeding\" alt=\"NPM package\" />\n  </a>\n  <a href=\"https://travis-ci.org/w3tecch/typeorm-seeding\">\n    <img src=\"https://travis-ci.org/w3tecch/typeorm-seeding.svg?branch=master\" alt=\"Build Status\" />\n  </a>\n  <a href=\"https://david-dm.org/w3tecch/typeorm-seeding\">\n    <img src=\"https://david-dm.org/w3tecch/typeorm-seeding/status.svg?style=flat\" alt=\"Dependency\" />\n  </a>\n    <a href=\"https://github.com/semantic-release/semantic-release\"><img src=\"https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\" alt=\"Sematic-Release\" /></a>\n</p>\n\n<p align=\"center\">\n  <b>A delightful way to seed test data into your database.</b></br>\n  <span>Inspired by the awesome framework <a href=\"https://laravel.com/\">laravel</a> in PHP and of the repositories from <a href=\"https://github.com/pleerock\">pleerock</a></span></br>\n  <sub>Made with ❤️ by <a href=\"https://github.com/hirsch88\">Gery Hirschfeld</a> and <a href=\"https://github.com/w3tecch/typeorm-seeding/graphs/contributors\">contributors</a></sub>\n</p>\n\n<br />\n\n## ❯ Table of contents\n\n- [Introduction](#-introduction)\n- [Installation](#-installation)\n- [Basic Seeder](#-basic-seeder)\n- [Using Entity Factory](#-using-entity-factory)\n- [Seeding Data in Testing](#-seeding-data-in-testing)\n- [Changelog](#-changelog)\n- [License](#-license)\n\n## ❯ Introduction\n\nIsn't it exhausting to create some sample data for your database, well this time is over!\n\nHow does it work? Just create a entity factory for your entities (models) and a seed script.\n\n### Entity\n\nFirst create your TypeORM entities.\n\n```typescript\n// user.entity.ts\n@Entity()\nexport class User {\n  @PrimaryGeneratedColumn('uuid') id: string\n  @Column({ nullable: true }) name: string\n  @Column({ type: 'varchar', length: 100, nullable: false }) password: string\n  @OneToMany((type) => Pet, (pet) => pet.user) pets: Pet[]\n\n  @BeforeInsert()\n  async setPassword(password: string) {\n    const salt = await bcrypt.genSalt()\n    this.password = await bcrypt.hash(password || this.password, salt)\n  }\n}\n\n// pet.entity.ts\n@Entity()\nexport class Pet {\n  @PrimaryGeneratedColumn('uuid') id: string\n  @Column() name: string\n  @Column() age: number\n  @ManyToOne((type) => User, (user) => user.pets)\n  @JoinColumn({ name: 'user_id' })\n  user: User\n}\n```\n\n### Factory\n\nThen for each entity define a factory. The purpose of a factory is to create new entites with generate data.\n\n> Note: Factories can also be used to generate data for testing.\n\n```typescript\n// user.factory.ts\ndefine(User, (faker: typeof Faker) => {\n  const gender = faker.datatype.number(1)\n  const firstName = faker.name.firstName(gender)\n  const lastName = faker.name.lastName(gender)\n\n  const user = new User()\n  user.name = `${firstName} ${lastName}`\n  user.password = faker.random.word()\n  return user\n})\n\n// pet.factory.ts\ndefine(Pet, (faker: typeof Faker) => {\n  const gender = faker.datatype.number(1)\n  const name = faker.name.firstName(gender)\n\n  const pet = new Pet()\n  pet.name = name\n  pet.age = faker.datatype.number()\n  pet.user = factory(User)() as any\n  return pet\n})\n```\n\n### Seeder\n\nAnd last but not least, create a seeder. The seeder can be called by the configured cli command `seed:run`. In this case it generates 10 pets with a owner (User).\n\n> Note: `seed:run` must be configured first. Go to [CLI Configuration](#cli-configuration).\n\n```typescript\n// create-pets.seed.ts\nexport default class CreatePets implements Seeder {\n  public async run(factory: Factory, connection: Connection): Promise<any> {\n    await factory(Pet)().createMany(10)\n  }\n}\n```\n\n## ❯ Installation\n\nBefore using this TypeORM extension please read the [TypeORM Getting Started](https://typeorm.io/#/) documentation. This explains how to setup a TypeORM project.\n\nAfter that install the extension with `npm` or `yarn`.\n\n```bash\nnpm i typeorm-seeding\n# or\nyarn add typeorm-seeding\n```\n\nOptional, install the type definitions of the `Faker` library.\n\n```bash\nnpm install -D @types/faker\n```\n\n### Configuration\n\nTo configure the path to your seeds and factories change the TypeORM config file (ormconfig.js or ormconfig.json).\n\n> The default paths are `src/database/{seeds,factories}/**/*{.ts,.js}`\n\n**ormconfig.js**\n\n```JavaScript\nmodule.exports = {\n  ...\n  seeds: ['src/seeds/**/*{.ts,.js}'],\n  factories: ['src/factories/**/*{.ts,.js}'],\n}\n```\n\n**.env**\n\n```\nTYPEORM_SEEDING_FACTORIES=src/factories/**/*{.ts,.js}\nTYPEORM_SEEDING_SEEDS=src/seeds/**/*{.ts,.js}\n```\n\n### CLI Configuration\n\nAdd the following scripts to your `package.json` file to configure the seed cli commands.\n\n```\n\"scripts\": {\n  \"seed:config\": \"ts-node ./node_modules/typeorm-seeding/dist/cli.js config\"\n  \"seed:run\": \"ts-node ./node_modules/typeorm-seeding/dist/cli.js seed\"\n  ...\n}\n```\n\nTo execute the seed run `npm run seed:run` in the terminal.\n\n> Note: More CLI options are [here](#cli-options)\n\nAdd the following TypeORM cli commands to the package.json to drop and sync the database.\n\n```\n\"scripts\": {\n  ...\n  \"schema:drop\": \"ts-node ./node_modules/typeorm/cli.js schema:drop\",\n  \"schema:sync\": \"ts-node ./node_modules/typeorm/cli.js schema:sync\",\n  ...\n}\n```\n\n#### CLI Options\n\n| Option                 | Default         | Description                                                                 |\n| ---------------------- | --------------- | --------------------------------------------------------------------------- |\n| `--seed` or `-s`       | null            | Option to specify a seeder class to run individually.                       |\n| `--connection` or `-c` | null            | Name of the typeorm connection. Required if there are multiple connections. |\n| `--configName` or `-n` | `ormconfig.js`  | Name to the typeorm config file.                                            |\n| `--root` or `-r`       | `process.cwd()` | Path to the typeorm config file.                                            |\n\n## ❯ Basic Seeder\n\nA seeder class only contains one method by default `run`. Within this method, you may insert data into your database. For manually insertion use the [Query Builder](https://typeorm.io/#/select-query-builder) or use the [Entity Factory](#-using-entity-factory)\n\n> Note. The seeder files will be executed alphabetically.\n\n```typescript\nimport { Factory, Seeder } from 'typeorm-seeding'\nimport { Connection } from 'typeorm'\nimport { User } from '../entities'\n\nexport default class CreateUsers implements Seeder {\n  public async run(factory: Factory, connection: Connection): Promise<any> {\n    await connection\n      .createQueryBuilder()\n      .insert()\n      .into(User)\n      .values([\n        { firstName: 'Timber', lastName: 'Saw' },\n        { firstName: 'Phantom', lastName: 'Lancer' },\n      ])\n      .execute()\n  }\n}\n```\n\n## ❯ Using Entity Factory\n\nOf course, manually specifying the attributes for each entity seed is cumbersome. Instead, you can use entity factories to conveniently generate large amounts of database records.\n\nFor all entities we want to create, we need to define a factory. To do so we give you the awesome [faker](https://github.com/marak/Faker.js/) library as a parameter into your factory. Then create your \"fake\" entity and return it. Those factory files should be in the `src/database/factories` folder and suffixed with `.factory` like `src/database/factories/user.factory.ts`.\n\n| Types           | Description                                                                     |\n| --------------- | ------------------------------------------------------------------------------- |\n| `Entity`         | TypeORM Entity like the user or the pet in the samples.                          |\n| `Context`       | Argument to pass some static data into the factory function.                    |\n| `EntityFactory` | This object is used to make new filled entities or create it into the database. |\n\n### `define`\n\nThe define function creates a new entity factory.\n\n```typescript\ndefine: <Entity, Context>(entity: Entity, factoryFn: FactoryFunction<Entity, Context>) => void;\n```\n\n```typescript\nimport Faker from 'faker'\nimport { define } from 'typeorm-seeding'\nimport { User } from '../entities'\n\ndefine(User, (faker: typeof Faker, context: { roles: string[] }) => { ... })\n```\n\n### `factory`\n\nFactory retrieves the defined factory function and returns the EntityFactory to start creating new enities.\n\n```typescript\nfactory: (entity: Entity) => (context?: Context) => EntityFactory<Entity, Context>\n```\n\n```typescript\nfactory(Pet)()\nfactory(Pet)({ name: 'Balou' })\n```\n\n### EntityFactory\n\n#### `map`\n\nUse the `.map()` function to alter the generated value before they get persisted.\n\n```typescript\nmap(mapFunction: (entity: Entity) => Promise<Entity>): EntityFactory<Entity, Context>\n```\n\n```typescript\nawait factory(User)()\n  .map(async (user: User) => {\n    const pets: Pet[] = await factory(Pet)().createMany(2)\n    const petIds = pets.map((pet: Pet) => pet.Id)\n    await user.pets().attach(petIds)\n  })\n  .createMany(5)\n```\n\n#### `make` & `makeMany`\n\nMake and makeMany executes the factory functions and return a new instance of the given entity. The instance is filled with the generated values from the factory function, but not saved in the database.\n\n**overrideParams** - Override some of the attributes of the entity.\n\n```typescript\nmake(overrideParams: EntityProperty<Entity> = {}): Promise<Entity>\n```\n\n```typescript\nawait factory(User)().make()\nawait factory(User)().makeMany(10)\n\n// override the email\nawait factory(User)().make({ email: 'other@mail.com' })\nawait factory(User)().makeMany(10, { email: 'other@mail.com' })\n```\n\n#### `create` & `createMany`\n\nthe create and createMany method is similar to the make and makeMany method, but at the end the created entity instance gets persisted in the database.\n\n**overrideParams** - Override some of the attributes of the entity.\n\n```typescript\ncreate(overrideParams: EntityProperty<Entity> = {}): Promise<Entity>\n```\n\n```typescript\nawait factory(User)().create()\nawait factory(User)().createMany(10)\n\n// override the email\nawait factory(User)().create({ email: 'other@mail.com' })\nawait factory(User)().createMany(10, { email: 'other@mail.com' })\n```\n\n## ❯ Seeding Data in Testing\n\nThe entity factories can also be used in testing. To do so call the `useSeeding` function, which loads all the defined entity factories.\n\nChoose your test database wisley. We suggest to run your test in a sqlite in memory database.\n\n```json\n{\n  \"type\": \"sqlite\",\n  \"name\": \"memory\",\n  \"database\": \":memory:\"\n}\n```\n\nHowever, if the test database is not in memory, than use the `--runInBand` flag to disable parallelizes runs.\n\n```typescript\ndescribe(\"UserService\", () => {\n  let connection: Connection\n\n  beforeAll(async (done) => {\n    connection = await useRefreshDatabase({ connection: 'memory' })\n    await useSeeding()\n\n    const user = await factory(User)().make()\n    const createdUser = await factory(User)().create()\n\n    await runSeeder(CreateUserSeed)\n    done()\n  })\n\n  afterAll(async (done) => {\n    await tearDownDatabase()\n    done()\n  })\n\n  test('Should ...', () => { ... })\n})\n```\n\n### `useSeeding`\n\nLoads the defined entity factories.\n\n```typescript\nuseSeeding(options: ConfigureOption = {}): Promise<void>\n```\n\n### `runSeeder`\n\nRuns the given seeder class.\n\n```typescript\nrunSeeder(seed: SeederConstructor): Promise<void>\n```\n\n### `useRefreshDatabase`\n\nConnects to the database, drops it and recreates the schema.\n\n```typescript\nuseRefreshDatabase(options: ConfigureOption = {}): Promise<Connection>\n```\n\n### `tearDownDatabase`\n\nCloses the open database connection.\n\n```typescript\ntearDownDatabase(): Promise<void>\n```\n\n### `ConfigureOption`\n\n```typescript\ninterface ConfigureOption {\n  root?: string // path to the orm config file. Default = process.cwd()\n  configName?: string // name of the config file. eg. ormconfig.js\n  connection?: string // name of the database connection.\n}\n```\n\n## ❯ Example Projects\n\n> Please fill free to add your open-source project here. This helps others to better understand the seeding technology.\n\n| Project                                                                                  | Description                                                                                                                    |\n| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |\n| [copa-ch/copa-backend](https://github.com/copa-ch/copa-backend/tree/master/src/database) | 🚀 Nest application written in TypeScript for the COPA project. This app manages your tournaments and generates the schedules. |\n\n## ❯ Changelog\n\n[Changelog](https://github.com/w3tecch/typeorm-seeding/releases)\n\n## ❯ License\n\n[MIT](LICENSE)\n","readmeFilename":"README.md"}