Giter Site home page Giter Site logo

Get api works on post or update api getting Cyclic dependency: "ProductCategory" TypeORMError: Cyclic dependency: "ProductCategory" about medusa HOT 5 CLOSED

veract-dev avatar veract-dev commented on June 12, 2024
Get api works on post or update api getting Cyclic dependency: "ProductCategory" TypeORMError: Cyclic dependency: "ProductCategory"

from medusa.

Comments (5)

adrien2p avatar adrien2p commented on June 12, 2024 1

can you try with the following

  @TreeParent()
  @JoinColumn({ name: "parent_category_id" })
  parent_category: Relation<ProductCategory> | null

  // Typeorm also keeps track of the category's parent at all times.
  @Column()
  parent_category_id: string | null

  @TreeChildren({ cascade: true })
  category_children: Relation<ProductCategory>[]

from medusa.

veract-dev avatar veract-dev commented on June 12, 2024 1

Thank you it worked

from medusa.

adrien2p avatar adrien2p commented on June 12, 2024 1

Glad to ear :D

from medusa.

adrien2p avatar adrien2p commented on June 12, 2024

You need to redefine the parent category as it rely on product category as well.

from medusa.

veract-dev avatar veract-dev commented on June 12, 2024

Tried both ways below still same issue.

models/product-category.ts

import { Column, Entity, Relation, Tree } from "typeorm"
import {
    // alias the core entity to not cause a naming conflict
    ProductCategory as MedusaProductCategory,
} from "@medusajs/medusa"

@Entity()
@Tree("materialized-path")
export class ProductCategory extends MedusaProductCategory {
    @Column()
    is_primary: boolean

    parent_category: Relation<ProductCategory> | null;
}
import { Column, Entity, Relation, Tree } from "typeorm"
import {
    // alias the core entity to not cause a naming conflict
    ProductCategory as MedusaProductCategory,
} from "@medusajs/medusa"

@Entity()
@Tree("materialized-path")
export class ProductCategory extends MedusaProductCategory {
    @Column()
    is_primary: boolean
    @Column({ type: 'character varying', nullable: true })
    parent_category: Relation<ProductCategory> | null;
}


from medusa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.