We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am only seeming to get one Comment per Post !
post.factory.ts
import * as Faker from 'faker'; import { define, factory } from 'typeorm-seeding-updated'; import { User } from '../../entity/User'; import { Post } from '../../entity/Post'; import { Comment } from '../../entity/Comment'; define(Post, (faker: typeof Faker) => { const post = new Post() post.text = faker.lorem.text(); post.user = factory(User)() as any; post.date = faker.date.past(3); return post; })
post.seed.ts
import * as faker from 'faker'; import { Seeder, Factory } from 'typeorm-seeding-updated' import { Post } from '../../entity/Post' import { Comment } from '../../entity/Comment' export default class CreatePosts implements Seeder { public async run(factory: Factory): Promise<void> { const posts = await factory(Post)({ roles: [] }).createMany(100); for (const post of posts) { const { id } = post; if (faker.datatype.number(1)) await factory(Comment)({ post:id }).createMany(faker.datatype.number(25)); } } }
comment.factory.ts
import * as Faker from 'faker'; import { define, factory } from 'typeorm-seeding-updated'; import { User } from '../../entity/User'; import { Post } from '../../entity/Post'; import { Comment } from '../../entity/Comment'; define(Comment, (faker: typeof Faker) => { const comment = new Comment() comment.text = faker.lorem.text(); comment.user = factory(User)() as any; comment.post = factory(Post)() as any; comment.date = faker.date.past(3); return comment; })
comment.seed.ts
import { Connection } from 'typeorm' import { Seeder, Factory } from 'typeorm-seeding-updated' import { Comment } from '../../entity/Comment' export default class CreateComments implements Seeder { public async run(factory: Factory, connection: Connection): Promise<any> { await factory(Comment)().createMany(100) } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am only seeming to get one Comment per Post !
post.factory.ts
post.seed.ts
comment.factory.ts
comment.seed.ts
The text was updated successfully, but these errors were encountered: