Comments (4)
Is it possible to use the factories without any database connection or calling useSeeding()
?
from typeorm-seeding.
By specific data do you mean data you can pass in to the factory?
Because you can pass in a settings
object which you yourself can define to receive in the factory.
import { Tag } from '../../tags/tags.entity';
import * as Faker from 'faker';
import { define } from 'typeorm-seeding';
define(Tag, (faker: typeof Faker, settings: { name: string }) => {
const tag = new Tag();
if (!!settings) {
tag.name = settings.name;
} else {
tag.name = faker.name.firstName();
}
return tag;
});
and then, customize the tag name using
let tag = await factory(Tag)({ name: 'delicious' }).seed();
which will result in the creation of a tag of name 'delicious'
from typeorm-seeding.
Hi @mcousillas6 & @eugenio165
Check out the seeding data in testing.
https://github.com/w3tecch/typeorm-seeding#-seeding-data-in-testing
from typeorm-seeding.
@hirsch88 @jorgebodega I also wonder, is that possible to not use database connection to test *.seed.ts
or *.factory.ts
files?
Like those (from example project) https://github.com/copa-ch/copa-backend/tree/master/src/database
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
- TypeError: Cannot read properties of undefined(reading 'number') HOT 3
- 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.