keystonejs / keystonejs/keystone

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

Open
#8,768 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
10k
Forks
1.3k
Avg merge
19h 14m
Merged PRs (30d)
19

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)

```sh
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

```sh
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

```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" },
}),
},
}),
};

```

Contributor guide

Open the contributing guide

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.