Skip to content

Commit

Permalink
stop object conversion of JSON type field (#104)
Browse files Browse the repository at this point in the history
Co-authored-by: NHT <[email protected]>
  • Loading branch information
nfesta2023 and hoangtuan910 authored Apr 5, 2024
1 parent 3d79bbf commit 05092a9
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 5 deletions.
32 changes: 30 additions & 2 deletions src/entity/cart-item.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,38 @@ export class CartItem {
@Column({ type: 'varchar', length: 255, unique: false, nullable: true })
public portion_customization: string;

@Column({ type: 'json', unique: false, nullable: false })
@Column({
type: 'json',
unique: false,
nullable: false,
transformer: {
// used to deserialize your data from db field value
from(val: object) {
return JSON.stringify(val);
},
// used to serialize your data to db field
to(val) {
return val;
},
},
})
public advanced_taste_customization_obj: string;

@Column({ type: 'json', unique: false, nullable: false })
@Column({
type: 'json',
unique: false,
nullable: false,
transformer: {
// used to deserialize your data from db field value
from(val: object) {
return JSON.stringify(val);
},
// used to serialize your data to db field
to(val) {
return val;
},
},
})
public basic_taste_customization_obj: string;

@Column({ type: 'text', unique: false, nullable: true })
Expand Down
16 changes: 15 additions & 1 deletion src/entity/menu-item.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,21 @@ export class MenuItem {
})
public is_vegetarian: number;

@Column({ type: 'json', nullable: false, unique: false })
@Column({
type: 'json',
nullable: false,
unique: false,
transformer: {
// used to deserialize your data from db field value
from(val: object) {
return JSON.stringify(val);
},
// used to serialize your data to db field
to(val) {
return val;
},
},
})
public cooking_schedule: string;

@Column({ type: 'int', nullable: false, unique: false })
Expand Down
32 changes: 30 additions & 2 deletions src/entity/order-sku.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,38 @@ export class OrderSKU {
@Column({ type: 'varchar', length: 255, nullable: true, unique: false })
public portion_customization: string;

@Column({ type: 'json', nullable: false, unique: false })
@Column({
type: 'json',
nullable: false,
unique: false,
transformer: {
// used to deserialize your data from db field value
from(val: object) {
return JSON.stringify(val);
},
// used to serialize your data to db field
to(val) {
return val;
},
},
})
public advanced_taste_customization_obj: string;

@Column({ type: 'json', nullable: false, unique: false })
@Column({
type: 'json',
nullable: false,
unique: false,
transformer: {
// used to deserialize your data from db field value
from(val: object) {
return JSON.stringify(val);
},
// used to serialize your data to db field
to(val) {
return val;
},
},
})
public basic_taste_customization_obj: string;

@Column({ type: 'text', nullable: true, unique: false })
Expand Down

0 comments on commit 05092a9

Please sign in to comment.