You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inserting the second user Jack returns the result CompanyID 0.
Name: Bob ➜ CompanyID: 1
Name: Jack ➜ CompanyID: 0
What do I have to do so that the user Jack also receives CompanyID 1? Basically, this is clear, because the company Gopher Inc. already exists through the first insert.
But wouldn't it be better for an UNIQUE constraint failed: companies.name to return the corresponding ID? That would significantly reduce the complexity of the queries. The relations are already defined by the structs. Or am I using the wrong method or the method in a wrong way?
Your Question
Inserting the second user
Jack
returns the resultCompanyID 0
.What do I have to do so that the user
Jack
also receivesCompanyID 1
? Basically, this is clear, because the companyGopher Inc.
already exists through the first insert.But wouldn't it be better for an
UNIQUE constraint failed: companies.name
to return the corresponding ID? That would significantly reduce the complexity of the queries. The relations are already defined by the structs. Or am I using the wrong method or the method in a wrong way?The document you expected this should be explained
Expected answer
The text was updated successfully, but these errors were encountered: