Comments (3)
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.
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:
from typeorm-seeding.
@andi-faizal94 Hi,
I think there's your problem bro
just adding ./
into path of module like import { UserEntity } from './../entities/user.entity'
from typeorm-seeding.
Related Issues (20)
- update major faker version please HOT 1
- Faker npm package not supported HOT 1
- Faker got abandoned and NPM audit complains about it HOT 1
- Support [email protected] HOT 2
- how to truncate tables? HOT 1
- There is a typo for the shebang in the dist/cli.js HOT 1
- Example for how to seed ManyToMany relation HOT 1
- [Request] Support for typeorm 0.3 and nestjs/typeorm v8.1.0 HOT 1
- Database connection failed! Check your typeORM config file. MissingDriverError: Wrong driver: "undefined" given. HOT 4
- this.subQuery is not a function HOT 1
- [Request] Support for typeorm 0.3 and nestjs/typeorm v8.1.0 HOT 20
- Replace `faker` with `@faker-js/faker` HOT 2
- Hello. I just have a question HOT 1
- TypeError: Cannot read properties of undefined (reading 'name')
- prevent seed:config to log any output
- How to seed data with monorepo workspace in nestjs HOT 4
- unable to resolve dependency tree HOT 8
- Publish 1.6.2 HOT 2
- Doesn't finish command
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typeorm-seeding.