-
Notifications
You must be signed in to change notification settings - Fork 376
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
Use my own tables to generate join tables? #276
Comments
You should be able to set the role.hasMany('app_modules', app_module, { ... }, {
merge_table: 'role_app_module'
}); |
Thanks for the reply? I did this :
It compiles (but wouldn't without the third empty argument) but when I call role.getApp_modules, it says the method doesn't exist. I also tried getApp_modules. Maybe underscores break how getters and setters are generated? |
Documentation needs to be added for this, but for now here's more options you can use in the association: db.models.role.hasMany('app_module', db.models.app_module, {}, {
mergeTable: 'role_app_module',
getAccessor: "getAppModules",
setAccessor: "setAppModules",
addAccessor: "setAppModules",
delAccessor: "removeAppModules",
hasAccessor: "hasAppModules"
}); If you don't set this options, it will create them based on the app_module. @spartan563 probably a good addition would be to have another key like |
Sounds like a good idea to me, I'll see about getting it added and tested sometime today. |
I'll also add a |
👍 |
Thank you very much for this! It was exactly what I needed. Also, SPARTAN563's addition worked very well for me! I think it would be a good addition to the docs! |
Has this commit been merged to the master branch? I updated ORM twice recently (now at 2.1.0) and I had to manually apply this commit after both updates |
Yes, there are a few pending issues that we have to close. The next release will surely have this merged already. And will be released as soon as we close those issues. |
Cool, thank you! |
I would like to know if it's possible to specify the join table name to use for a hasMany association? I would like to keep my SQL structure and test data from the application, but in some instances it's not possible in hasMany relations. My table names use underscores as well as my properties.
If for example I want to have a table role and a table app_module, linked by role_app_module, it doesn't work with hasMany. Is this possible to have a solution for this?
Thanks
The text was updated successfully, but these errors were encountered: