Next.js Discord

Discord Forum

How can I store multiline text in the postgreSql db using prisma and use that data in next.js app

Unanswered
Segugio Italiano posted this in #help-forum
Open in Discord
Segugio ItalianoOP
I have this prisma schema model
model Test{
  id          String    @id @default(uuid())
  title       String
  description String
  profile     Profile   @relation(fields: [profileId], references: [id])
  profileId   String
}


I want to store the description as multiline points.
e.g:
1. This is first line
2. This is second line
3. This is third line

How should I store this data so that I can show data in exact same way in browser.

  <p className="">{test.description}</p>

2 Replies

you could split by \n to get each line, and then map to ol list, or if you dont need the 1,2,3 you can just use (and sure you have something like whitespace-break-spaces/white-space: break-spaces;)
Tonkinese
Just store it as a string. There's no reason to split it up. There's nothing magic about multi-line strings. What is displayed as a new line is actually just a \n and computers choose to display it as a new line. It's not actually multiple strings.