1 import { model } from "@medusajs/framework/utils"
2 import Product from "./product"
3
4 const ProductCollection = model
5 .define("ProductCollection", {
6 id: model.id({ prefix: "pcol" }).primaryKey(),
7 title: model.text().searchable().translatable(),
8 handle: model.text(),
9 external_id: model.text().nullable(),
10 metadata: model.json().nullable(),
11 products: model.hasMany(() => Product, {
12 mappedBy: "collection",
13 }),
14 })
15 .indexes([
16 {
17 name: "IDX_collection_handle_unique",
18 on: ["handle"],
19 unique: true,
20 where: "deleted_at IS NULL",
21 },
22 ])
23
24 export default ProductCollection