Skip to content

Instantly share code, notes, and snippets.

@adevinwild
Created December 29, 2022 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adevinwild/de05148bd50a0e75ba3e453bbbd08ca5 to your computer and use it in GitHub Desktop.
Save adevinwild/de05148bd50a0e75ba3e453bbbd08ca5 to your computer and use it in GitHub Desktop.
ExtendedStoreEntity for Medusa
import { Store as MedusaStore } from "@medusajs/medusa/dist";
import { Column, Entity, JoinColumn, OneToMany } from "typeorm";
import { Entity as MedusaEntity } from "medusa-extender";
import { User } from "../../user/entities/user.entity";
import { ProductVariant } from "../../product-variant/entities/product-variant.entity";
@MedusaEntity({ override: MedusaStore })
@Entity()
export class Store extends MedusaStore {
@OneToMany(() => User, (user) => user.store)
@JoinColumn({ name: "id", referencedColumnName: "store_id" })
members: User[];
@OneToMany(() => ProductVariant, (productVariant) => productVariant.store)
@JoinColumn({ name: "id", referencedColumnName: "store_id" })
products: ProductVariant[];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment