In my development stack, I am utilizing a MySQL database along with TypeORM and ExpressJS.
I have established two entities: User and Client, which are connected by a one-to-one relationship with the Client holding a foreign key.
Upon attempting to save a client, I encountered the following error:
Error Message: Cannot perform update query because update values are not defined. Call "qb.set(...)" method to specify updated values
User Entity Details:
export class User extends BaseEntity {
@PrimaryGeneratedColumn()
id: number
// Rest of the entity's properties...
}
Client Entity Details:
@Entity()
export class Client extends BaseEntity {
@PrimaryGeneratedColumn()
id: number
// Rest of the entity's properties...
}
An excerpt from the auth.service code, responsible for saving a client:
// Code snippet detailing the process of creating and saving a client
// Including user creation, position retrieval, and client creation/saving logic
On removing the user
column from the Client entity, both the User and Client entities are saved as standalone entities without forming a relational link between them. However, it is essential to establish this connection between the two.
What went wrong in this scenario?
How can I rectify this issue to ensure the proper establishment of the relationship between User and Client entities?