{"size": 588, "ext": "js", "max_stars_repo_path": "database/queries.js", "max_stars_repo_name": "imsolost/goovy", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "database/queries.js", "max_issues_repo_name": "imsolost/goovy", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "database/queries.js", "max_forks_repo_name": "imsolost/goovy", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 42.0, "max_line_length": 127, "alphanum_fraction": 0.6666666667}
const pgp = require('pg-promise')()
const connectionString = `pg://${process.env.USER}@localhost:5432/moviesdb`
const db = pgp( connectionString )

exports.queries = {
  findByEmail: (email) => db.one('SELECT * FROM users WHERE email = $1', [email]),

  create: (email, password) => db.one('INSERT INTO users (email, password) VALUES ($1, $2) RETURNING (id)', [email, password]),

  historyById: (user_id) => db.any('SELECT * FROM history WHERE user_id = $1', [user_id]),

  history: (user_id, movie) => db.none('INSERT INTO history (user_id, movie) VALUES ($1, $2)', [user_id, movie])
}
