-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
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
[Question] how would you see setting attributes that are related to each other? #4
Comments
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 ! |
Unless there is a bug with the implementation, I'll close this issue |
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
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! |
If you need more information, you can have a look at typeorm 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. If you need any kind of custom logic in your save method, you could write your own adapter to suit your needs. |
Apologies if this is a dense question, but in this example I want the
name
andcode
to be related - e.g. thecode
should be the lowercase value ofname
- butname
is generated using faker (or chancejs, etc).Do you have a suggested pattern in terms of how to handle this situation?
Thanks for the work so far on this tool, seems useful!
The text was updated successfully, but these errors were encountered: