{"_id":"@aaronngray/typeorm-seeding","name":"@aaronngray/typeorm-seeding","dist-tags":{"latest":"6.0.1"},"versions":{"6.0.1":{"author":{"name":"Gery Hirschfeld","email":"gery.hirschfeld@w3tec.ch","url":"https://github.com/hirsch88"},"bin":{"typeorm-seeding":"dist/cli.js"},"contributors":[{"name":"Jorge Bodega","email":"jorge.bodega.f@gmail.com","url":"https://github.com/jorgebodega"},{"name":"Aaron Gray","email":"aaronngray@gmail.com","url":"https://github.com/AaronNGray"}],"dependencies":{"chalk":"4.1.2","commander":"11.0.0","glob":"10.3.4","ora":"5.4.1","tslib":"2.6.2"},"description":"🌱 A delightful way to seed test data into your database.","devDependencies":{"@faker-js/faker":"8.0.2","@jorgebodega/typeorm-factory":"1.4.0","@tsconfig/node18-strictest":"1.0.0","@types/glob":"8.1.0","@types/jest":"29.5.4","@types/node":"18.17.15","@typescript-eslint/eslint-plugin":"6.7.0","@typescript-eslint/parser":"6.7.0","eslint":"8.49.0","eslint-config-prettier":"9.0.0","eslint-plugin-import":"2.28.1","jest":"29.6.4","prettier":"3.0.3","rimraf":"5.0.1","sqlite3":"5.1.6","ts-jest":"29.1.1","ts-node":"10.9.1","typeorm":"0.3.17","typescript":"4.9.5"},"engines":{"node":">=16, !=17, >=20.6.1"},"keywords":["typeorm","seed","seeding","orm"],"license":"MIT","main":"dist/index.js","name":"@aaronngray/typeorm-seeding","packageManager":"pnpm@8.7.5","peerDependencies":{"typeorm":"^0.3.17"},"repository":{"type":"git","url":"git+https://github.com/AaronNGray/typeorm-seeding.git"},"scripts":{"build":"tsc --project ./tsconfig.build.json","checks":"pnpm format:ci && pnpm lint:ci && pnpm typecheck","format":"prettier --write \"{src,test}/**/*.ts\"","format:ci":"prettier --check \"{src,test}/**/*.ts\"","lint":"eslint \"{src,test}/**/*.ts\"","lint:fix":"pnpm lint --fix","lint:ci":"pnpm lint","prebuild":"rimraf dist","seed:run":"ts-node ./src/cli.ts seed","test":"jest","test:ci":"jest --silent","test:cov":"jest --coverage --silent","test:watch":"jest --watch","typecheck":"tsc --noEmit"},"types":"dist/index.d.ts","version":"6.0.1","_id":"@aaronngray/typeorm-seeding@6.0.1","gitHead":"84796555aead7afb2cca1071af68f850b3240a13","bugs":{"url":"https://github.com/AaronNGray/typeorm-seeding/issues"},"homepage":"https://github.com/AaronNGray/typeorm-seeding#readme","_nodeVersion":"20.6.1","_npmVersion":"9.8.1","dist":{"integrity":"sha512-dYuPXc9+9i5srNY4SOmUUbrR9syvYlsTbU9SEc33VEA0jwU47GXbf/4dOXfai+/9JtYQ279bc2o0N7LCwTVBiw==","shasum":"f403d917c712f07299f001d6d60c93c473209f98","tarball":"https://registry.npmjs.org/@aaronngray/typeorm-seeding/-/typeorm-seeding-6.0.1.tgz","fileCount":65,"unpackedSize":43083,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHaCOzBP9jrC8G20AZ5wOhU0tM52vCcvaq0wUurC7fUgAiEAz04vWXJmq6wnh/2XlFW8iZ7NVGflUl3glWFjbdteSRw="}]},"_npmUser":{"name":"aarongray.org","email":"aaronngray@gmail.com"},"directories":{},"maintainers":[{"name":"aarongray.org","email":"aaronngray@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/typeorm-seeding_6.0.1_1695083293427_0.8085088884360414"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-19T00:28:13.296Z","6.0.1":"2023-09-19T00:28:13.694Z","modified":"2023-09-19T00:28:14.013Z"},"maintainers":[{"name":"aarongray.org","email":"aaronngray@gmail.com"}],"description":"🌱 A delightful way to seed test data into your database.","homepage":"https://github.com/AaronNGray/typeorm-seeding#readme","keywords":["typeorm","seed","seeding","orm"],"repository":{"type":"git","url":"git+https://github.com/AaronNGray/typeorm-seeding.git"},"contributors":[{"name":"Jorge Bodega","email":"jorge.bodega.f@gmail.com","url":"https://github.com/jorgebodega"},{"name":"Aaron Gray","email":"aaronngray@gmail.com","url":"https://github.com/AaronNGray"}],"author":{"name":"Gery Hirschfeld","email":"gery.hirschfeld@w3tec.ch","url":"https://github.com/hirsch88"},"bugs":{"url":"https://github.com/AaronNGray/typeorm-seeding/issues"},"license":"MIT","readme":"<p align=\"center\">\n  <img src=\"./logo.png\" alt=\"logo\" width=\"160\" />\n</p>\n<h1 align=\"center\" style=\"text-align: center;\">TypeORM Seeding</h1>\n\n<p align=\"center\">\n  <img alt=\"License\" src=\"https://img.shields.io/npm/l/@jorgebodega/typeorm-seeding?style=for-the-badge\">\n  <a href=\"https://github.com/semantic-release/semantic-release\">\n    <img src=\"https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release&style=for-the-badge\" alt=\"Semantic release\" />\n  </a>\n  <a href='https://coveralls.io/github/jorgebodega/typeorm-seeding'>\n    <img alt=\"Coveralls master branch\" src=\"https://img.shields.io/coveralls/github/jorgebodega/typeorm-seeding/master?style=for-the-badge\">\n  </a>\n</p>\n\n\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, <a href=\"https://mikro-orm.io/docs/next/seeding/\">MikroORM seeding</a>  and the repositories from <a href=\"https://github.com/pleerock\">pleerock</a></span></br>\n</p>\n\n<p align=\"center\">\n  <sub>Made with ❤️ by <a href=\"https://github.com/hirsch88\">Gery Hirschfeld</a>, <a href=\"https://github.com/jorgebodega\">Jorge Bodega</a> and <a href=\"https://github.com/w3tecch/typeorm-seeding/graphs/contributors\">contributors</a></sub>\n</p>\n\n<br />\n\n# Contents\n\n- [Seeder](#seeder-1)\n  - [run](#run)\n- [CLI](#cli-configuration)\n  - [seed](#seed)\n- [Testing features](#testing-features)\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`. Add development flag if you are not using seeders nor factories in production code.\n\n```bash\nnpm i [-D] @jorgebodega/typeorm-seeding\nyarn add [-D] @jorgebodega/typeorm-seeding\npnpm add [-D] @jorgebodega/typeorm-seeding\n```\n\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 and/or seed script.\n\n### Entity\n\n```typescript\n@Entity()\nclass User {\n  @PrimaryGeneratedColumn('increment')\n  id!: number\n\n  @Column()\n  name!: string\n\n  @Column()\n  lastName!: string\n\n  @Column()\n  email!: string\n\n  @OneToMany(() => Pet, (pet) => pet.owner)\n  pets?: Pet[]\n\n  @ManyToOne(() => Country, (country) => country.users, { nullable: false })\n  @JoinColumn()\n  country!: Country\n}\n```\n\n### Seeder\n\n```typescript\nclass UserSeeder extends Seeder {\n  async run(dataSource: DataSource) {\n    const users: User[] = [...]\n    await dataSource.createEntityManager().save<User>(users)\n  }\n}\n```\n\n# Seeder\n\nSeeder class is how we provide a way to insert data into databases, and could be executed by the command line or by helper method. Is an abstract class with one method to be implemented, and a helper function to run some more seeder sequentially.\n\n```typescript\nclass UserSeeder extends Seeder {\n  async run(dataSource: DataSource) {\n    ...\n  }\n}\n```\n\nThis seeder class must be exported as default to be handled by the CLI.\n\n```typescript\nexport default class UserSeeder extends Seeder {\n  async run(dataSource: DataSource) {\n    ...\n  }\n}\n```\n\n## `run`\n\nThis function is the one that needs to be defined when extending the class.\n\n```typescript\nrun(dataSource: DataSource): Promise<void>\n```\n\n```typescript\nasync run(dataSource: DataSource) {\n    const users: User[] = [...]\n    await dataSource.createEntityManager().save<User>(users)\n}\n```\n\n# CLI Configuration\n\nThere is a command that allows you to execute multiple seeders from cli.\n\n```bash\ntypeorm-seeding seed -d path/to/datasource src/seeders/*.ts\n```\n\nAdd the following script to your `package.json` file to configure them.\n\n```json\n\"scripts\": {\n  \"seed:run\": \"typeorm-seeding seed -d path/to/datasource\",\n  ...\n}\n```\n\n## `seed`\n\nThis command execute a seeder, that could be specified as a parameter. Glob pattern is supported.\n\n```bash\ntypeorm-seeding -d [...] seed <paths>\n```\n\nCLI command only executes default seeders.\n\n##### Options\n\n| Option                 | Default                              | Description                                           |\n| ---------------------- | ------------------------------------ | ----------------------------------------------------- |\n| `--dataSource` or `-d` |                                      | Path of the data source                               |\n\n# Testing features\n\nWe provide some testing features that we already use to test this package, like connection configuration.\nThe entity factories can also be used in testing. To do so call the `useFactories` or `useSeeders` function.\n\n## `useSeeders`\n\nExecute one or more seeders.\n\n```typescript\nuseSeeders(entrySeeders: ClassConstructor<Seeder> | ClassConstructor<Seeder>[]): Promise<void>\nuseSeeders(\n  entrySeeders: ClassConstructor<Seeder> | ClassConstructor<Seeder>[],\n  customOptions: Partial<ConnectionConfiguration>,\n): Promise<void>\n```\n\n## `useDataSource`\n\nUse specific data source on the factories. If the data source is not initialized when provided, can be initialized with the `forceInitialization` flag.\n\n```typescript\nuseDataSource(dataSource: DataSource): Promise<void>\nuseDataSource(dataSource: DataSource, overrideOptions: Partial<DataSourceOptions>): Promise<void>\nuseDataSource(dataSource: DataSource, forceInitialization: boolean): Promise<void>\nuseDataSource(\n  dataSource: DataSource,\n  overrideOptions: Partial<DataSourceOptions>,\n  forceInitialization: boolean,\n): Promise<void>\n```\n\n# Factory\n\nFactory related code has been removed from this package, now on [@jorgebodega/typeorm-factory](https://github.com/jorgebodega/typeorm-factory).","readmeFilename":"README.md"}