Replies: 1 comment
-
Any help with this? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Using LB4 + MySQL DB through loopback-connector-mysql
A
{id: string, name: string}
B
{id: string, aId:string, name: string}
To create those models, I've used this code:
A
B
On both tables, id is a VARCHAR(255), although it only needs a VARCHAR(36)
On B table, aId is a VARCHAR(512), which is even worse... This could be solved by defining aId as follows:
@belongsTo(() => A, undefined, { length: 36, }) aId: string;
Now, b.aId is a VARCHAR(36), but then i get the error following error: "Error: UNKNOWN_CODE_PLEASE_REPORT: Referencing column 'aId' and referenced column 'id' in foreign key constraint 'fk_a_b_aId' are incompatible", because both VARCHAR have different size.
How can I define the id property's length on DB?
Thank you
Beta Was this translation helpful? Give feedback.
All reactions