-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Custom Column/Property Names #3372
Comments
Transferred to @letynsoft , it would be something like:
Please see my example in here: https://github.com/dhmlau/loopback4-example-todo-customized#if-i-have-a-table-name-or-column-name-that-is-different-from-the-model-name-and-property-what-should-i-change. |
Thanks for the reply, tried that, but it doesn't seem to work with mssql connector:
The strange thing is that the mssql connector get's confused and thinks there is the 'shift_id' column but only 'shiftId' exists at that moment... |
Have you migrated the database after asking the column to be named as below?:
Sounds to me that it is the most likely source of confusion. |
Yes i have tried migrating, that's the issue. The migration process doesn't acknowledge this correctly and fails. |
Hello. Can you tell me about your quick-fix, please? |
Hi, @model({ settings: { sqlite3: { table: 'categories', } } }) 2/ I also make a dummy test in a property and it doesn't work. @property({ type: 'number', id: true, generated: true, sqlite3: { columnName: 'CAT_ID', }, sqlite: { columnName: 'CAT_ID', } }) id?: number; 3/ ow to define the database column name for @belongsTo annotation ? Thanks in advance for your response. |
@letynsoft @Hideart hi, we have documented it on our site, the Relation metadata section shows how to customize your foreign key name and db column names. Please try it out and let us know if it works. @sestienne I don't think we support sqlite3, you might need to use MySQL connector. |
Closing due to inactivity. |
Description/Steps to reproduce
Hi,
Is there any way how to specify a custom column name using the @Property decorator with loopback4?
I have following property
But the mssql connector (migrate script) doesn't seem to support this (is attemping to create duplicate columns, ...).
I have wrote a little quick-fix (rewriting modelDefinition when define() is called), but that's ugly
Expected result
To migrate the schema
Actual Result
Additional information
$ node -e 'console.log(process.platform, process.arch, process.versions.node)'
linux x64 10.16.0
$ npm ls --prod --depth 0 | grep loopback
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── [email protected]
The text was updated successfully, but these errors were encountered: