{"id":42589579,"url":"https://github.com/linnify/typeorm-factory","last_synced_at":"2026-01-28T23:09:42.793Z","repository":{"id":39744675,"uuid":"337483781","full_name":"linnify/typeorm-factory","owner":"linnify","description":"Typeorm factory that makes testing easier","archived":false,"fork":false,"pushed_at":"2023-02-04T16:24:49.000Z","size":581,"stargazers_count":29,"open_issues_count":11,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-04T10:15:22.168Z","etag":null,"topics":["entity","factory","nodejs","testing","typeorm","typeorm-factory","typescript"],"latest_commit_sha":null,"homepage":"https://linnify.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linnify.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-09T17:32:53.000Z","updated_at":"2025-05-13T09:41:02.000Z","dependencies_parsed_at":"2023-02-06T12:40:19.810Z","dependency_job_id":null,"html_url":"https://github.com/linnify/typeorm-factory","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/linnify/typeorm-factory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linnify%2Ftypeorm-factory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linnify%2Ftypeorm-factory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linnify%2Ftypeorm-factory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linnify%2Ftypeorm-factory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linnify","download_url":"https://codeload.github.com/linnify/typeorm-factory/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linnify%2Ftypeorm-factory/sbom","scorecard":{"id":591168,"data":{"date":"2025-08-11","repo":{"name":"github.com/linnify/typeorm-factory","commit":"fcce5bddce61d99b28b379d43e7eaf74f08e8995"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 1/20 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: ISC License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 15 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"23 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22","Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-jqv5-7xpx-qj74","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-fx4w-v43j-vc45","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T21:55:57.140Z","repository_id":39744675,"created_at":"2025-08-20T21:55:57.140Z","updated_at":"2025-08-20T21:55:57.140Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28854546,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T22:56:21.783Z","status":"ssl_error","status_checked_at":"2026-01-28T22:56:00.861Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["entity","factory","nodejs","testing","typeorm","typeorm-factory","typescript"],"created_at":"2026-01-28T23:09:42.266Z","updated_at":"2026-01-28T23:09:42.788Z","avatar_url":"https://github.com/linnify.png","language":"TypeScript","readme":"# Typeorm Factory\n\n\n[![codecov](https://codecov.io/gh/linnify/typeorm-factory/branch/main/graph/badge.svg)](https://codecov.io/gh/linnify/typeorm-factory)\n[![Build Status](https://travis-ci.com/linnify/typeorm-factory.svg?branch=main)](https://travis-ci.com/linnify/typeorm-factory)\n\nThis package makes testing easier by creating factories for your TypeORM entities. It is inspired by the python package [Factory Boy](https://github.com/FactoryBoy/factory_boy).\n\n## Installation\n\n#### NPM\n\n```bash\nnpm install @linnify/typeorm-factory --save-dev\n```\n\n#### Yarn\n\n```bash\nyarn add @linnify/typeorm-factory --dev\n```\n\n\n## Usage\n\nThis section provides examples on how to use this library's features.\n\n### Factories\n\n#### Declaration\n\nFor declaring a factory, we make use of typescript classes and add as properties on the class the fields from our entity with the desired values\n\n```typescript\nimport { Factory } from '@linnify/typeorm-factory';\n\nexport class NormalUserFactory extends Factory\u003cUser\u003e {\n  entity = User;\n  \n  firstName = 'John'\n  lastName = 'Doe'\n  email = 'john.doe@typeorm-factory.com'\n  role = 'normal_user'\n}\n\nexport class AdminUserFactory extends Factory\u003cUser\u003e {\n  entity = User;\n\n  firstName = 'Admin'\n  lastName = 'Factory'\n  email = 'admin@typeorm-factory.com'\n  role = 'admin'\n}\n```\n\n#### Usage\n\nAfter defining our factories, we can make use of them by creating a new instance of a factory:\n\n```typescript\nconst userFactory: NormalUserFactory = new NormalUserFactory();\n```\n\nWhen creating the factory, we make use of the `create` function. By default, the entity is created and saved to the database by using the properties defined on the factory.\n\n```typescript\nconst user: User = await userFactory.create();\n```\n\nIf we want to modify the default attributes from the factory, we add them as parameter to the `create` function:\n\n\n```typescript\nconst user: User = await userFactory.create({firstName: 'AnotherFirstName', lastName: 'AnotherLastName'});\n```\n\nWe can create multiple instances by using the `createMany` function. In the below example we create 5 users:\n\n```typescript\nconst users: User[] = await userFactory.createMany(5)\n```\n\nIn the case when we have some unique attributes by which we define entities. We do not want to create multiple objects with some properties, we make use of the `getOrCreate` function. We define the attributes by which the entity should be unique. Calling the `create` method multiple times will return the same object.\n\nIn our example, we do not want to create 2 users with the same email.\n\n```typescript\nimport { Factory } from '@linnify/typeorm-factory';\n\nexport class NormalUserFactory extends Factory\u003cUser\u003e {\n  ...\n\n  protected getOrCreate(): string[] {\n    return ['email'];\n  }\n}\n...\n\n// Creates the user \nconst user: User = await userFactory.create();\n\n// Gets the user that was created above\nconst sameUser: User = await userFactory.create();\n\n```\n### SubFactories\n\nA common case is that the entities have relations between them. In this case we create factories for all the entities and make use of `SubFactory` to create a link between them.\n\n#### Example\n\nIf the user has multiple addresses we add the `UserFactory` as a subfactory on the `AddressFactory`\n\n```typescript\nimport { Factory, SubFactory } from '@linnify/typeorm-factory';\n\nexport class AddressFactory extends Factory\u003cAddress\u003e {\n  street = 'Factory Street'\n  number = '100'\n  user = new SubFactory(UserFactory)\n}\n```\n\n### Sequences\n\nWe can add sequences on our factories when we want a property to have a different every time we create an object using the same factory\n\n```typescript\nimport { Factory, Sequence } from '@linnify/typeorm-factory';\n\nexport class NormalUserFactory extends Factory\u003cUser\u003e {\n  ...\n  email = new Sequence((i: number) =\u003e `john.doe.${i}@typeorm-factory.com`)\n\n}\n```\n\n### Post Generations\n\nSometimes we have the need to call some functions after the object was created. For this, we have created a `PostGeneration` decorator that can be used on multiple functions and all of them will be called after the entity was created.\n\n```typescript\nimport { Factory, PostGeneration } from '@linnify/typeorm-factory';\n\nexport class NormalUserFactory extends Factory\u003cUser\u003e {\n  ...\n  \n  @PostGeneration()\n  addLogsForUser() {\n    // create some logs for the created user\n  }\n  \n  @PostGeneration()\n  async anotherFunctionToBeCalled(createdUser: User) {\n    // do something with the created user\n  }\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinnify%2Ftypeorm-factory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinnify%2Ftypeorm-factory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinnify%2Ftypeorm-factory/lists"}