UNPKG

libpiggy

Version:

Use a PostgreSQL database like a JSON document store.

42 lines (32 loc) 981 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator"); var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const tableExists = (() => { var _ref = (0, _asyncToGenerator3.default)(function* ({ client, table, store }) { client = client || store.client; try { const text = `SELECT EXISTS ( SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = '${table}' );`; const results = yield client.query({ text }); return { client, results, exists: results.rows[0].exists }; } catch (error) { throw error; } }); return function tableExists(_x) { return _ref.apply(this, arguments); }; })(); exports.default = tableExists;