Skip to content

Conversation

@lucleray
Copy link
Member

@lucleray lucleray commented Sep 14, 2018

const sql = require('@sequencework/sql/pg')

// main method stays the same
const query = sql`select * from movies where id = ${id}` 

// default pg result object : https://node-postgres.com/api/result
const { rows, rowCount } = await sql.query(db)`select * from movies` 

// helpers
const movies = await sql.many(db)`select * from movies`
const movie = await sql.one(db)`select * from movies where id = ${id}`
const nbMovie = await sql.count(db)`update from movies set name = ${name} where id = ${id}`

@lucleray lucleray requested a review from yannvgn September 14, 2018 11:52
Copy link
Collaborator

@yannvgn yannvgn left a comment

Choose a reason for hiding this comment

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

Let's merge that!

Copy link
Collaborator

@yannvgn yannvgn left a comment

Choose a reason for hiding this comment

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

wait, readme has to be updated

@lucleray lucleray merged commit 72aaeb4 into master Sep 15, 2018
@lucleray lucleray deleted the add-methods-pg-shorthand branch September 15, 2018 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants