[Question] How to create WordPress datamodel?
See original GitHub issueI’m using a MySQL database to store different content types (i.e companies, jobs, events, etc) which are all linked to each other and all have tags and hierarchical categories.
The structure of my database is very similar to the WordPress database, however, all the meta fields for each content type are stored in a separate *_Meta table instead of one single meta table.
Is it possible to do this in Prisma 2? If so, how should I define my datamodel so I can do a query like below?
Below is my data model definition:
enum ContentStatus {
ACTIVE
DRAFT
PENDING
DELETED
}
enum ContentType {
COMPANY
JOB
EVENT
}
model User {
id: Int @id
name: String!
email: String @unique
password: String!
createdAt DateTime @default(now())
}
model Content {
id: Int @id @unique
title: String!
description: String!
excerpt: String!
status: ContentStatus! @default(ACTIVE)
slug: String @unique
type: ContentType! @default(COMPANY)
createdBy: User
createdAt: DateTime @default(now())
updatedAt: DateTime @updatedAt
}
model CompanyMeta {
id: Int @id @unique
content: Content
events: Content! @relation(link: TABLE, name: "CompanyEventRelationships")
incorporated: DateTime!
email: String
phone: String
in_url: String
fb_url: String
}
model EventMeta {
id: Int @id @unique
content: Content
company: Content! @relation(link: TABLE, name: "CompanyEventRelationships")
startDate: DateTime
endDate: DateTime
price: Int
registrationUrl: String
}
model CompanyEventRelationships @relationTable {
id: Int @id
company: Content
event: Content
}
enum TaxonomyType {
CATEGORY
TAG
}
model Term {
id: Int @id @unique
name: String
slug: String @unique
term_group: Int @default(value: 0)
}
model TermTaxonomy {
id: ID! @unique
term: Term! @relation(link: INLINE) @default(value: 0)
taxonomy: TaxonomyType!
description: String?
parent: Term! @relation(link: INLINE) @default(value: 0)
count: Int @default(value: 0)
}
model TermRelationship {
content: Content! @relation(link: INLINE) @default(value: 0)
term_taxonomy: TermTaxonomy! @relation(link: INLINE) @default(value: 0)
order: Int @default(value: 0)
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Create datamodel for WordPress taxonomies and terms
Hi,. I'm planning to create the same WordPress database structure in a MySQL prismaDB. Has anybody implemented a datamodel for WordPress ...
Read more >custom data model - link and populate from admin backend
My question is, given I am doing some complex functions that require models and queries that don't fit neatly into the WP conception...
Read more >Creating a Custom Table with PHP in WordPress
Creating a new table in the database used by WordPress is as simple as writing the SQL statement to create it, and then...
Read more >Beginner's Guide To WordPress Database Schema & Structure
A database is created whenever you build a WordPress website. Everything on your WordPress website, be it posts, custom post type, pages, ...
Read more >WordPress – Behind the Scenes, Part 2 - Vertabelo
The model has to be flexible enough to accommodate all the different plugins. Of course, plugin creators can add custom tables for specific ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I went ahead and introspected a wordpress instance for you, this should give you a good idea:
I think you are considering Prisma to be a GraphQL ORM which it is not.
You will need to implement these in your GraphQL server.
But I do think we can provide an example for this once the Relay style pagination part of the photon is ready(https://github.com/prisma/specs/blob/photonjs-improvements/specs/PhotonJS.md#todo-withpageinfo)