So i extended the entiy of products, to add a value called "views", this is what i've done:
product model:
import { Column, Entity } from "typeorm"
import {
// alias the core entity to not cause a naming conflict
Product as MedusaProduct,
} from "@medusajs/medusa"
@Entity()
export class Product extends MedusaProduct {
@Column()
views: number
}
import { registerOverriddenValidators } from "@medusajs/medusa"
import {
AdminPostProductsReq as MedusaAdminPostProductsReq,
} from "@medusajs/medusa/dist/api/routes/admin/products/create-product"
import { IsString, IsNumber, IsOptional } from "class-validator"
class AdminPostProductsReq extends MedusaAdminPostProductsReq {
@IsNumber()
views: number
}
registerOverriddenValidators(AdminPostProductsReq)
I am sending a create product request with title, and the views value and its creating the product successfully, however i look at my products table in postgres and its still 0, the default value
help in why its not updating would be appreciated 🙏
note: the product is being added however the logs are saying "error: An error occurred while processing product.created: QueryFailedError: null value in column "title" of relation "product" violates not-null constraint"
Hello!
So i extended the entiy of products, to add a value called "views", this is what i've done:
product model:
index.d.ts because i am using typescript:
migration script:
my index.ts code in src/api/index.ts:
I am sending a create product request with title, and the views value and its creating the product successfully, however i look at my products table in postgres and its still 0, the default value
help in why its not updating would be appreciated 🙏
note: the product is being added however the logs are saying "error: An error occurred while processing product.created: QueryFailedError: null value in column "title" of relation "product" violates not-null constraint"