pragma.js 536 B

123456789101112
  1. 'use strict';
  2. const { getBooleanOption, cppdb } = require('../util');
  3. module.exports = function pragma(source, options) {
  4. if (options == null) options = {};
  5. if (typeof source !== 'string') throw new TypeError('Expected first argument to be a string');
  6. if (typeof options !== 'object') throw new TypeError('Expected second argument to be an options object');
  7. const simple = getBooleanOption(options, 'simple');
  8. const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
  9. return simple ? stmt.pluck().get() : stmt.all();
  10. };