forked from w3tecch/typeorm-seeding
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE definition function has been substituted with attrs
- Loading branch information
1 parent
ad40cd0
commit 4a2ce08
Showing
9 changed files
with
69 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { FactorizedAttrs, LazyAttributeCallback } from './types' | ||
|
||
export class LazyAttribute<T> { | ||
constructor(private callback: LazyAttributeCallback<T>) {} | ||
|
||
resolve(entity: T): FactorizedAttrs<T> { | ||
return this.callback(entity) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import type { ConnectionOptions as TypeORMConnectionOptions } from 'typeorm' | ||
|
||
export type ClassConstructor<T> = new () => T | ||
import type { Factory } from './factory' | ||
|
||
export type ConnectionOptions = TypeORMConnectionOptions & { | ||
seeders: string[] | ||
defaultSeeder: string | ||
} | ||
|
||
export type ConnectionConfiguration = { | ||
root?: string | ||
configName?: string | ||
connection: string | ||
} | ||
export type Constructable<T> = new () => T | ||
export type FactorizedAttrs<T> = { | ||
[K in keyof Partial<T>]: T[K] | (() => T[K] | Promise<T[K]>) | Factory<T[K]> | ||
} | ||
export type LazyAttributeCallback<T> = (entity: T) => FactorizedAttrs<T> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
import faker from '@faker-js/faker' | ||
import { Factory } from '../../src/factory' | ||
import { Pet } from '../entities/Pet.entity' | ||
import { UserFactory } from './User.factory' | ||
|
||
export class PetFactory extends Factory<Pet> { | ||
protected async definition(): Promise<Pet> { | ||
const pet = new Pet() | ||
|
||
pet.name = faker.name.findName() | ||
pet.owner = new UserFactory() as any | ||
|
||
return pet | ||
protected entity = Pet | ||
protected attrs = { | ||
name: faker.name.findName(), | ||
lastName: async () => faker.name.findName(), | ||
// owner: new UserFactory() as any, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.