mirror of
https://github.com/Such-Software/medusa-plugin-blog.git
synced 2026-10-20 05:58:33 +02:00
start models
This commit is contained in:
+4
-5
@@ -18,16 +18,15 @@
|
||||
],
|
||||
"devDependencies": {
|
||||
"@medusajs/medusa": "^1.10.1",
|
||||
"@medusajs/types": "^1.8.5",
|
||||
"@medusajs/utils": "^1.8.4",
|
||||
"body-parser": "^1.19.0",
|
||||
"cors": "^2.8.5",
|
||||
"cross-env": "^5.2.1",
|
||||
"express": "^4.17.2",
|
||||
"jest": "^25.5.4",
|
||||
"medusa-core-utils": "^1.2.0",
|
||||
"medusa-interfaces": "^1.3.7",
|
||||
"medusa-test-utils": "^1.1.40",
|
||||
"typescript": "^4.9.5",
|
||||
"typeorm": "^0.3.16"
|
||||
"typeorm": "^0.3.16",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "cross-env NODE_ENV=production yarn run build",
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Product, Customer } from "@medusajs/medusa"
|
||||
import { BaseEntity, generateEntityId } from "@medusajs/utils"
|
||||
import { BeforeInsert, Column, Entity, Index, JoinColumn, ManyToOne, OneToMany } from "typeorm"
|
||||
|
||||
@Entity()
|
||||
export class BlogCategory extends BaseEntity {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "post")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import { Product, Customer } from "@medusajs/medusa"
|
||||
import { BaseEntity, generateEntityId } from "@medusajs/utils"
|
||||
import { BeforeInsert, Column, Entity, Index, JoinColumn, ManyToOne, OneToMany } from "typeorm"
|
||||
import { BlogCategory } from "./blog-category"
|
||||
import { BlogTag } from "./blog-tag"
|
||||
|
||||
@Entity()
|
||||
export class BlogPost extends BaseEntity {
|
||||
|
||||
@Index({ unique: true })
|
||||
@Column({ type: "text", nullable: true })
|
||||
handle: string | null
|
||||
|
||||
@Column()
|
||||
title: string
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
content: string | null
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
author: string | null
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
description: string | null
|
||||
|
||||
@Column({ type: "text", nullable: true, array: true })
|
||||
keywords: string | null
|
||||
|
||||
@Column({ type: "jsonb", nullable: true })
|
||||
tags: string | null
|
||||
|
||||
@ManyToOne(() => BlogCategory)
|
||||
@JoinColumn({ name: "category_id" })
|
||||
category: BlogCategory
|
||||
|
||||
@Column({ type: "boolean", nullable: false })
|
||||
published: boolean
|
||||
|
||||
|
||||
|
||||
@ManyToOne(() => BlogCategory)
|
||||
@JoinColumn({ name: "product_id" })
|
||||
product: Product
|
||||
|
||||
@Column({ type: "varchar", nullable: false })
|
||||
customer_id: string
|
||||
|
||||
@ManyToOne(() => Product)
|
||||
@JoinColumn({ name: "customer_id" })
|
||||
customer: Customer
|
||||
|
||||
|
||||
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "post")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Product, Customer } from "@medusajs/medusa"
|
||||
import { BaseEntity, generateEntityId } from "@medusajs/utils"
|
||||
import { BeforeInsert, Column, Entity, Index, JoinColumn, ManyToOne, OneToMany } from "typeorm"
|
||||
|
||||
@Entity()
|
||||
export class BlogTag extends BaseEntity {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "post")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user