Skip to content

Fix data types examples #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions content/features/5-types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PostgreSQL has a rich system of supported [data types](https://www.postgresql.or
node-postgres will convert a database type to a JavaScript string if it doesn't have a registered type parser for the database type. Furthermore, you can send any type to the PostgreSQL server as a string and node-postgres will pass it through without modifying it in any way. To circumvent the type parsing completely do something like the following.

```js
const queryText = 'select int_col::string, date_col::string, json_col::string from my_table'
const queryText = 'SELECT int_col::text, date_col::text, json_col::text FROM my_table'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOPS - thanks for catching this!

const result = await client.query(queryText)

console.log(result.rows[0]) // will contain the unparsed string value of each column
Expand Down Expand Up @@ -67,7 +67,7 @@ await client.query(createTableText)

// insert the current time into it
const now = new Date()
const insertText = 'INSERT INTO dates(date_col, timestamp_col, timestamtz_col'
const insertText = 'INSERT INTO dates(date_col, timestamp_col, timestamtz_col) VALUES ($1, $2, $3)'
await client.query(insertText, [now, now, now])

// read the row back out
Expand Down