nestjs-boilerplate
nestjs-boilerplate copied to clipboard
add custom property
Hi guys, Is it possible to add a property with a complex type in a relational database without a one-to-many relationship?
example: suppose this sudo complex type keeps action information :
ActionObject: {
actionResult,
actionDate,
actionOperator}
and I could use it in my domain :
{
verificationStatus:ActionObject;
migrationStatus:ActionObject;
}
I try to find a way that doesn't use multiple separate props for a single status like :
verifiedDate: Date | null;
@Column({ type: 'jsonb', nullable: true })
verifiedResult: object | null;
@Column({ type: 'string', nullable: true })
verifiedOperator: Date | null;
If is not possible could we add a simple property that mapps to an Enum?
Try to store the entire ActionObject as a single jsonb column.
@Entity()
export class UserAction {
@PrimaryGeneratedColumn()
id: number;
@Column({ type: 'jsonb', nullable: true })
verificationStatus: ActionObject;
@Column({ type: 'jsonb', nullable: true })
migrationStatus: ActionObject;
}
Somewhat like this.