Giter Club home page Giter Club logo

Comments (3)

jorgebodega avatar jorgebodega commented on June 17, 2024 1

Hi! Can you just put some more explicit example, or maybe create a repo to reproduce this? Just because you talked about gender but I cannot see that on entity

from typeorm-seeding.

andi-faizal94 avatar andi-faizal94 commented on June 17, 2024

Hi! Can you just put some more explicit example, or maybe create a repo to reproduce this? Just because you talked about gender but I cannot see that on entity

Hi
I'm sorry about it:

my case in Entity:
import { Entity, PrimaryGeneratedColumn, Column, BaseEntity } from "typeorm";

@entity()
export class User extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;

@column()
firstName: string;

@column()
lastName: string;

@column()
age: number;

@column({ nullable: true })
addres: string;
}

And I have a file user.factory.ts :

import * as Faker from "faker";
import { define } from "typeorm-seeding";
import { User } from "../../entity/User";

define(User, (faker: typeof Faker) => {
const gender = faker.datatype.number(1);
const firstName = faker.name.firstName(gender);
const lastName = faker.name.lastName(gender);
const age = faker.datatype.number(1);
const addres = faker.random.word();

const user = new User();
user.firstName = firstName;
user.lastName = lastName;
user.age = age;
user.addres = addres;
return user;
});

I fix with :

Change column User entity:
@PrimaryGeneratedColumn("uuid")
id: string;

Change faker.random.number:
const gender = faker.random.uuid();
const age = faker.random.number({ min: 10, max: 20 });
Change In Package.json:
"seed:run": "ts-node ./node_modules/typeorm-seeding/dist/cli.js seed"
change with:

"seed:run": "ts-node ./node_modules/typeorm-seeding/dist/cli.js --configName ./ormconfig.json seed"

this is work to me.

My Repository:

https://github.com/andi-faizal94/RESTfull-API-TYPEORM-Express-PostgreSQL/blob/main/src/database/factories/user.factory.ts

from typeorm-seeding.

richoandika avatar richoandika commented on June 17, 2024

@andi-faizal94 Hi,
I think there's your problem bro
image
just adding ./ into path of module like import { UserEntity } from './../entities/user.entity'

from typeorm-seeding.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.