Comments (4)
Hi Kevin, I'm really happy this lib is useful to someone else than me. I have some plans to extend it to work outside of typeorm but I'm giving myself some time to think about it
You can achieve what you want with what I called LazyAttribute. You can apply a function which get as an argument the instance to be created. In your case, it means you could access your name property !
There is an example in the readme about LazyAttribute
from factory.
Unless there is a bug with the implementation, I'll close this issue
from factory.
Thanks so much for taking the time to make the tool.
I spent some time looking at some of the other options and like your approach. Clearly I should have spent some more time reading your documentation instead :).
I will take a look at the LazyAttribute, it sounds like what I want!
One other unrelated note (I can make an issue if you want for tracking?) - I think it might be useful to add more information about HOW the persistence works with TypeORM. You have
The adapter allows you to persist your data. If you want to save your data in a database via typeorm, you can use the TypeormAdapter. Default Adapter is ObjectAdapter and does not persist anything. You can create your own adapter to persist your data the way you want.
But it isn't clear to me from this documentation alone how this actually works, or what the intended work flow would be here. I will likely use this for seeding some basic data in lower dev / sandbox environments, or potentially for end-to-end testing, and I can always try to open a PR with more details if I get to it.
For now, thanks again, I'll close out this issue!
from factory.
If you need more information, you can have a look at typeorm
This project does not aim to document typeorm features.
But you can also use this lib without using typeorm !
It is quite common when using factories, seeding etc... to have data being persisted in a database, a file or whatever.
Factory
uses a method called save
to persist data. If no adapter is provided, this method does... almost nothing. Adapters, like the typeorm one, allow you to use typeorm features and save the data in your database. What is not written in my documentation is how typeorm should be setup, how you open a connection to your database etc... This should be covered on their documentation though.
If you need any kind of custom logic in your save method, you could write your own adapter to suit your needs.
from factory.
Related Issues (5)
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 factory.