-
Notifications
You must be signed in to change notification settings - Fork 281
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
allow additional options to be specified for associations #42
allow additional options to be specified for associations #42
Conversation
Codecov Report
@@ Coverage Diff @@
## master #42 +/- ##
==========================================
+ Coverage 94.5% 94.67% +0.16%
==========================================
Files 65 65
Lines 692 713 +21
Branches 91 99 +8
==========================================
+ Hits 654 675 +21
Misses 14 14
Partials 24 24
Continue to review full report at Codecov.
|
@hackedbychinese thanks for implementing this. Looks good.
is not an issue. I will merge it anyway |
Hello! Any comment on when we might see this in a release? Thanks! |
@hackedbychinese Hey, I removed the AssociationForeignKeyOptions from the So that the following example, which shows your implementation.. @ForeignKey(() => Model, {name: 'fooId', field: 'foo_id'})
fooId: number; ..should be achieved with @ForeignKey(() => Model)
@Column({field: 'foo_id'})
fooId: number; I think that this approach makes the api much cleaner. What do you think? Additionally I added support for |
Sure, that makes sense. Thanks! |
Affects
BelongsTo
,BelongsToMany
,HasMany
,HasOne
, andForeignKey
attributes. Compatibility with existing parameter that takes string name of foreign keys has been provided by letting the foreign key be a string (existing functionality) or the appropriate association options (new functionality). Additionally,ForeignKey
can now receive options. By default it simply sets the foreign key name to the property name, which should be backwards compatible.I did not add tests for the Many-to-Many cases, because additional options outside setting the FK column names and table name are mostly superfluous.
Fixes #34