`document` filed not support rich text using `text` type in database?

Open
#8,768 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
typescript
Domain
content, databases

Research direction

Start by comparing the Article.body definitions in prisma.schema, generated prisma.ts, and schema.ts. Trace how document() is mapped to the database and determine what behavior is expected for rich text stored in a text column. A complete result should clarify whether this mapping is supported and identify the relevant test or schema-generation change.

Written by the indexing model from the issue text.

Description

I am using text type store rich text in db,This is the exist prisma.schema in another project(Article.body is the column to store rich text)

model Category {
  id       Int       @id @default(autoincrement())
  title    String
  articles Article[]
}

model Article {
  id         Int      @id @default(autoincrement())
  category   Category @relation(fields: [categoryId], references: [id])
  categoryId Int
  createdAt  DateTime @default(now())
  updatedAt  DateTime @default(now())
  isDeleted  Boolean  @default(false)
  orgLink    String   @default("")
  thumbnail  String
  title      String
  body       String   @db.Text
  overview   String   @default("")
}

And this is generate by prisma.ts in keystone

model Category {
  id       Int       @id @default(autoincrement())
  title    String    @default("")
  articles Article[] @relation("Article_category")
}

model Article {
  id         Int       @id @default(autoincrement())
  category   Category? @relation("Article_category", fields: [categoryId], references: [id])
  categoryId Int?      @map("category")
  createdAt  DateTime? @default(now())
  updatedAt  DateTime? @default(now())
  isDeleted  Boolean   @default(false)
  orgLink    String    @default("")
  thumbnail  String    @default("")
  title      String    @default("")
  body       Json      @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
  overview   String    @default("")

  @@index([categoryId])
}

and the schema.ts

export const lists: Lists = {
  Category: list({
    access: allowAll,
    fields: {
      title: text(),
      articles: relationship({
        ref: "Article.category",
        many: true,
      }),
    },
  }),
  Article: list({
    access: allowAll,
    fields: {
      category: relationship({
        ref: "Category.articles",
        many: false,
      }),
      createdAt: timestamp({
        defaultValue: { kind: "now" },
      }),
      updatedAt: timestamp({
        defaultValue: { kind: "now" },
      }),
      isDeleted: checkbox({ defaultValue: false }),
      orgLink: text({ defaultValue: "" }),
      thumbnail: text(),
      title: text(),
      body: document(),
      overview: text(),
    },
  }),
  Admin: list({
    access: allowAll,
    fields: {
      name: text({ validation: { isRequired: true } }),
      email: text({
        validation: { isRequired: true },
        isIndexed: "unique",
      }),
      password: password({ validation: { isRequired: true } }),
      createdAt: timestamp({
        defaultValue: { kind: "now" },
      }),
    },
  }),
};

Dominant language
TypeScript
Stars
10k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
38

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from keystonejs/keystone

All issues in keystonejs/keystone

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.