<commit_before>const pgp = require('pg-promise')
const sqlbuilder = require('./sqlbuilder')

function insert (table, data) {
  const {sql, params} = sqlbuilder.insert(table, data)
  return this.query(sql, params)
}

function update (table, data, where) {
  const {sql, params} = sqlbuilder.update(table, data, where)
  return this.query(sql, params)
}

function upsert (table, data, where) {
  const {sql, params} = sqlbuilder.upsert(table, data, where)
  return this.query(sql, params)
}

function batchUpsert (upserts) {
  return this
    .tx((t) => t
      .batch(upserts
        .map(args => {
          const {sql, params} = sqlbuilder.upsert(...args)
          return t.query(sql, params)
        })))
}

module.exports = (options) => (connection) => Object.assign({
  insert,
  update,
  upsert,
  batchUpsert
}, pgp(options)(connection))<commit_msg>Actually exposed the delete function<commit_after>const pgp = require('pg-promise')
const sqlbuilder = require('./sqlbuilder')

function insert (table, data) {
  const {sql, params} = sqlbuilder.insert(table, data)
  return this.query(sql, params)
}

function update (table, data, where) {
  const {sql, params} = sqlbuilder.update(table, data, where)
  return this.query(sql, params)
}

function upsert (table, data, where) {
  const {sql, params} = sqlbuilder.upsert(table, data, where)
  return this.query(sql, params)
}

function del (table, where) {
  const {sql, params} = sqlbuilder.del(table, where)
  return this.query(sql, params)
}

function batchUpsert (upserts) {
  return this
    .tx((t) => t
      .batch(upserts
        .map(args => {
          const {sql, params} = sqlbuilder.upsert(...args)
          return t.query(sql, params)
        })))
}

module.exports = (options) => (connection) => Object.assign({
  insert,
  update,
  upsert,
  batchUpsert,
  del
}, pgp(options)(connection))
{'fraction_non_alphanumeric': 0.14814814814814814, 'fraction_numerical': 0.0, 'mean_word_length': 3.6834170854271355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6659938', 'n_tokens_mistral': 613, 'n_tokens_neox': 619, 'n_words': 158}