<commit_before>var scrub = require('pg-format');

function getFromEnv() {
  var config = {};
  config.jsonTable = process.env.POSTGRESQL_TABLE;
  config.jsonCol = process.env.POSTGRESQL_COLUMN;
  return config;
}

exports.createTable = function() {
  var c = getFromEnv();
  return scrub('CREATE TABLE %I (%I jsonb);', c.jsonTable, c.jsonCol);
};

exports.addColumnToTable = function() {
  var c = getFromEnv();
  return scrub('ALTER TABLE %I ADD COLUMN %I jsonb;', c.jsonTable, c.jsonCol);
};

exports.checkTableSyntax = function() {
  var c = getFromEnv();
  return scrub('SELECT count(%I) FROM %I;', c.jsonCol, c.jsonTable);
};

exports.insertIntoColumn = function(data) {
  var c = getFromEnv();
  return scrub('INSERT INTO %I (%I) VALUES %L;', c.jsonTable, c.jsonCol, data);
};

exports.fetchEntries = function () {
  var c = getFromEnv();
  return scrub('SELECT %I->\'_id\' AS _id, %I->\'_rev\' AS _rev FROM %I', c.jsonCol, c.jsonCol, c.jsonTable);<commit_msg>strategically indexing the JSONB<commit_after>var scrub = require('pg-format');

function getFromEnv() {
  var config = {};
  config.jsonTable = process.env.POSTGRESQL_TABLE;
  config.jsonCol = process.env.POSTGRESQL_COLUMN;
  return config;
}

exports.createTable = function() {
  var c = getFromEnv();
  return scrub('CREATE TABLE %I (%I jsonb); CREATE INDEX %I ON %I ( (%I->>\'_id\') ); CREATE INDEX %I ON %I ( (%I->>\'type\') ); CREATE INDEX %I ON %I USING GIN ( (%I->\'_attachments\') );', c.jsonTable, c.jsonCol, [c.jsonTable, c.jsonCol, 'uuid'].join('_'), c.jsonTable, c.jsonCol, [c.jsonTable, c.jsonCol, 'type'].join('_'), c.jsonTable, c.jsonCol, [c.jsonTable, c.jsonCol, 'attachments'].join('_'), c.jsonTable, c.jsonCol);
};

exports.addColumnToTable = function() {
  var c = getFromEnv();
  return scrub('ALTER TABLE %I ADD COLUMN %I jsonb;', c.jsonTable, c.jsonCol);
};

exports.checkTableSyntax = function() {
  var c = getFromEnv();
  return scrub('SELECT count(%I) FROM %I;', c.jsonCol, c.jsonTable);
};

exports.insertIntoColumn = function(data) {
  var c = getFromEnv();
  return scrub('INSERT INTO %I (%I) VALUES %L;', c.jsonTable, c.jsonCol, data);
};

exports.fetchEntries = function () {
  var c = getFromEnv();
  return scrub('SELECT %I->\'_id\' AS _id, %I->\'_rev\' AS _rev FROM %I', c.jsonCol, c.jsonCol, c.jsonTable);
{'fraction_non_alphanumeric': 0.18552232336367577, 'fraction_numerical': 0.0, 'mean_word_length': 4.508353221957041, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '2935061', 'n_tokens_mistral': 838, 'n_tokens_neox': 834, 'n_words': 209}