Insert line break in Postgres

I am trying to insert line breaks ('\n') into a text field in Postgres. I saw that I am supposed to do the following: https://stackoverflow.com/questions/36028908/postgresql-newline-character I would like to know if folks here have a solution without making a raw query to the database each time one of the field may store line breaks?
Stack Overflow
PostgreSQL newline character
How to use newline character in PostgreSQL? This is an incorrect script from my experiment: select 'test line 1''\n''test line 2'; I want the sql editor display this result from my script ab...
1 Reply
rphlmr ⚡
rphlmr ⚡4mo ago
This should work as expected:
await db.insert(posts).values({
content: `line1
line2`,
contentAlt: "line1\nline2",
});
await db.insert(posts).values({
content: `line1
line2`,
contentAlt: "line1\nline2",
});
Want results from more Discord servers?
Add your server