feat(medusa): Add metadata to Product Category (#5599)

*  feat(migrations): add metadata column to product_category table in database to store additional information about each product category

*  feat(product-category.ts): add metadata field to ProductCategory model to store additional details
📝 docs(product-category.ts): add documentation for new metadata field in ProductCategory model

*  feat(product-category.ts): add metadata field to ProductCategoryInput type to support additional data

*  feat(ProductCategory.ts): add optional metadata field to ProductCategory model to store additional details

*  feat(product-categories): add metadata field to product categories for additional information storage
📝 docs(product-categories): add documentation for new metadata field in product categories

*  feat(product-categories): add 'metadata' field to default and allowed product category fields for enhanced data tracking

*  feat(product-category.ts): add metadata support to product categories
🔧 refactor(product-category.ts): import setMetadata from utils to handle metadata setting in a more efficient way

*  feat(models): add metadata field to AdminPostProductCategoriesCategoryReq and AdminPostProductCategoriesReq models to store additional information

* 📝 docs(api-reference): add metadata field to ProductCategory schema in both admin and store specs
🔧 fix(api-reference): make metadata field required in ProductCategory schema to ensure data consistency

* Create nine-fishes-matter.md

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Bastien
2023-11-16 20:37:02 +01:00
committed by GitHub
co-authored by Oli Juhl
parent 57573ed4d7
commit b3093c3e3d
14 changed files with 110 additions and 3 deletions
@@ -1,6 +1,7 @@
import { generateEntityId } from "../utils/generate-entity-id"
import { BaseEntity } from "../interfaces/models/base-entity"
import { kebabCase } from "lodash"
import { DbAwareColumn } from "../utils/db-aware-column"
import { Product } from "."
import {
BeforeInsert,
@@ -64,6 +65,9 @@ export class ProductCategory extends BaseEntity {
@Column({ nullable: false, default: 0 })
rank: number
@DbAwareColumn({ type: "jsonb", nullable: true })
metadata: Record<string, unknown>
@ManyToMany(() => Product, { cascade: ["remove", "soft-remove"] })
@JoinTable({
name: ProductCategory.productCategoryProductJoinTable,
@@ -105,6 +109,7 @@ export class ProductCategory extends BaseEntity {
* - id
* - is_active
* - is_internal
* - metadata
* - mpath
* - name
* - parent_category_id
@@ -173,4 +178,12 @@ export class ProductCategory extends BaseEntity {
* description: The date with timezone at which the resource was updated.
* type: string
* format: date-time
* metadata:
* description: An optional key-value map with additional details
* nullable: true
* type: object
* example: {car: "white"}
* externalDocs:
* description: "Learn about the metadata attribute, and how to delete and update it."
* url: "https://docs.medusajs.com/development/entities/overview#metadata-attribute"
*/