Skip to content
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

Add helpers functions to sql(db) #4

Merged
merged 15 commits into from
Sep 15, 2018
Merged

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.

2 participants