Compare commits
3 Commits
5517a0ba1d
...
35af57732e
Author | SHA1 | Date | |
---|---|---|---|
35af57732e | |||
fa986fcdc9 | |||
494cd97442 |
423
lib/pawsqlite.js
423
lib/pawsqlite.js
@ -1,102 +1,70 @@
|
|||||||
module.exports =
|
/******/ (() => { // webpackBootstrap
|
||||||
/******/ (function(modules) { // webpackBootstrap
|
/******/ "use strict";
|
||||||
/******/ // The module cache
|
/******/ var __webpack_modules__ = ({
|
||||||
/******/ var installedModules = {};
|
|
||||||
/******/
|
/***/ "./src/adapter_wrapper.mjs":
|
||||||
/******/ // The require function
|
/*!*********************************!*\
|
||||||
/******/ function __webpack_require__(moduleId) {
|
!*** ./src/adapter_wrapper.mjs ***!
|
||||||
/******/
|
\*********************************/
|
||||||
/******/ // Check if module is in cache
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||||
/******/ if(installedModules[moduleId]) {
|
|
||||||
/******/ return installedModules[moduleId].exports;
|
__webpack_require__.r(__webpack_exports__);
|
||||||
/******/ }
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
/******/ // Create a new module (and put it into the cache)
|
/* harmony export */ "wrapAdapter": () => (/* binding */ wrapAdapter)
|
||||||
/******/ var module = installedModules[moduleId] = {
|
/* harmony export */ });
|
||||||
/******/ i: moduleId,
|
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
|
||||||
/******/ l: false,
|
|
||||||
/******/ exports: {}
|
|
||||||
/******/ };
|
|
||||||
/******/
|
function wrapAdapter(adapter) {
|
||||||
/******/ // Execute the module function
|
const wrapped = {};
|
||||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
||||||
/******/
|
["name", "open", "close", "delete", "sql"].forEach((prop) => {
|
||||||
/******/ // Flag the module as loaded
|
if (!(prop in adapter)) {
|
||||||
/******/ module.l = true;
|
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__.PawSQLiteError(`Invalid adapter: missing property: ${ prop }`);
|
||||||
/******/
|
}
|
||||||
/******/ // Return the exports of the module
|
|
||||||
/******/ return module.exports;
|
if (
|
||||||
/******/ }
|
prop === "name" && !(
|
||||||
/******/
|
typeof adapter[prop] === "string" ||
|
||||||
/******/
|
adapter[prop] instanceof String
|
||||||
/******/ // expose the modules object (__webpack_modules__)
|
) ||
|
||||||
/******/ __webpack_require__.m = modules;
|
prop !== "name" && (
|
||||||
/******/
|
typeof adapter[prop] !== "function"
|
||||||
/******/ // expose the module cache
|
)
|
||||||
/******/ __webpack_require__.c = installedModules;
|
) {
|
||||||
/******/
|
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__.PawSQLiteError("Invalid adapter: invalid type for property: " +
|
||||||
/******/ // define getter function for harmony exports
|
prop);
|
||||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
}
|
||||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
||||||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
if (typeof adapter[prop] === "function") {
|
||||||
/******/ }
|
wrapped[prop] = async (...args) => {
|
||||||
/******/ };
|
try {
|
||||||
/******/
|
return await adapter[prop](...args);
|
||||||
/******/ // define __esModule on exports
|
} catch (err) {
|
||||||
/******/ __webpack_require__.r = function(exports) {
|
throw _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__.PawSQLiteError.from(err);
|
||||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
}
|
||||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
};
|
||||||
/******/ }
|
} else {
|
||||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
wrapped[prop] = adapter[prop];
|
||||||
/******/ };
|
}
|
||||||
/******/
|
});
|
||||||
/******/ // create a fake namespace object
|
|
||||||
/******/ // mode & 1: value is a module id, require it
|
return wrapped;
|
||||||
/******/ // mode & 2: merge all properties of value into the ns
|
}
|
||||||
/******/ // mode & 4: return value when already ns object
|
|
||||||
/******/ // mode & 8|1: behave like require
|
/***/ }),
|
||||||
/******/ __webpack_require__.t = function(value, mode) {
|
|
||||||
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
||||||
/******/ if(mode & 8) return value;
|
|
||||||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
||||||
/******/ var ns = Object.create(null);
|
|
||||||
/******/ __webpack_require__.r(ns);
|
|
||||||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
||||||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
||||||
/******/ return ns;
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
||||||
/******/ __webpack_require__.n = function(module) {
|
|
||||||
/******/ var getter = module && module.__esModule ?
|
|
||||||
/******/ function getDefault() { return module['default']; } :
|
|
||||||
/******/ function getModuleExports() { return module; };
|
|
||||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
||||||
/******/ return getter;
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // Object.prototype.hasOwnProperty.call
|
|
||||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
||||||
/******/
|
|
||||||
/******/ // __webpack_public_path__
|
|
||||||
/******/ __webpack_require__.p = "";
|
|
||||||
/******/
|
|
||||||
/******/
|
|
||||||
/******/ // Load entry module and return exports
|
|
||||||
/******/ return __webpack_require__(__webpack_require__.s = "./src/pawsqlite.mjs");
|
|
||||||
/******/ })
|
|
||||||
/************************************************************************/
|
|
||||||
/******/ ({
|
|
||||||
|
|
||||||
/***/ "./src/database.mjs":
|
/***/ "./src/database.mjs":
|
||||||
/*!**************************!*\
|
/*!**************************!*\
|
||||||
!*** ./src/database.mjs ***!
|
!*** ./src/database.mjs ***!
|
||||||
\**************************/
|
\**************************/
|
||||||
/*! exports provided: Database */
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||||
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
__webpack_require__.r(__webpack_exports__);
|
__webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
|
/* harmony export */ "Database": () => (/* binding */ Database)
|
||||||
|
/* harmony export */ });
|
||||||
/* harmony import */ var _transaction_manager_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./transaction_manager.mjs */ "./src/transaction_manager.mjs");
|
/* harmony import */ var _transaction_manager_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./transaction_manager.mjs */ "./src/transaction_manager.mjs");
|
||||||
|
|
||||||
|
|
||||||
@ -108,7 +76,7 @@ class Database {
|
|||||||
this.version = null;
|
this.version = null;
|
||||||
this.path = null;
|
this.path = null;
|
||||||
|
|
||||||
this.transactionManager = new _transaction_manager_mjs__WEBPACK_IMPORTED_MODULE_0__["TransactionManager"](dbName, this.adapter);
|
this.transactionManager = new _transaction_manager_mjs__WEBPACK_IMPORTED_MODULE_0__.TransactionManager(dbName, this.adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
async open() {
|
async open() {
|
||||||
@ -169,13 +137,13 @@ class Database {
|
|||||||
/*!*********************!*\
|
/*!*********************!*\
|
||||||
!*** ./src/log.mjs ***!
|
!*** ./src/log.mjs ***!
|
||||||
\*********************/
|
\*********************/
|
||||||
/*! exports provided: log, enableDebug */
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||||
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
__webpack_require__.r(__webpack_exports__);
|
__webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "log", function() { return log; });
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "enableDebug", function() { return enableDebug; });
|
/* harmony export */ "log": () => (/* binding */ log),
|
||||||
|
/* harmony export */ "enableDebug": () => (/* binding */ enableDebug)
|
||||||
|
/* harmony export */ });
|
||||||
let DEBUG = false;
|
let DEBUG = false;
|
||||||
|
|
||||||
function log(...args) {
|
function log(...args) {
|
||||||
@ -196,107 +164,16 @@ function enableDebug(active) {
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ "./src/pawsqlite.mjs":
|
|
||||||
/*!***************************!*\
|
|
||||||
!*** ./src/pawsqlite.mjs ***!
|
|
||||||
\***************************/
|
|
||||||
/*! exports provided: default */
|
|
||||||
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
__webpack_require__.r(__webpack_exports__);
|
|
||||||
/* harmony import */ var _database_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database.mjs */ "./src/database.mjs");
|
|
||||||
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
|
|
||||||
/* harmony import */ var _log_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./log.mjs */ "./src/log.mjs");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const adapters = [];
|
|
||||||
|
|
||||||
|
|
||||||
/* harmony default export */ __webpack_exports__["default"] = ({
|
|
||||||
open: async function(dbName, options = {}) {
|
|
||||||
const adapter = getAdapter(options.adapter);
|
|
||||||
|
|
||||||
let db = new _database_mjs__WEBPACK_IMPORTED_MODULE_0__["Database"](dbName, adapter);
|
|
||||||
await db.open();
|
|
||||||
return db;
|
|
||||||
},
|
|
||||||
delete: function(dbName, options = {}) {
|
|
||||||
const adapter = getAdapter(options.adapter);
|
|
||||||
|
|
||||||
return adapter.delete(dbName);
|
|
||||||
},
|
|
||||||
registerAdapter: function(adapter) {
|
|
||||||
adapters.push(wrapAdapter(adapter));
|
|
||||||
},
|
|
||||||
debug: _log_mjs__WEBPACK_IMPORTED_MODULE_2__["enableDebug"],
|
|
||||||
Error: _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
function wrapAdapter() {
|
|
||||||
const wrapped = {};
|
|
||||||
|
|
||||||
["name", "open", "close", "delete", "sql"].forEach((prop) => {
|
|
||||||
if (!(prop in adapter)) {
|
|
||||||
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"](`Invalid adapter: missing property: ${ prop }`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
prop === "name" && !(
|
|
||||||
typeof adapter[prop] === "string" ||
|
|
||||||
adapter[prop] instanceof String
|
|
||||||
) ||
|
|
||||||
prop !== "name" && (
|
|
||||||
typeof adapter[prop] !== "function"
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]("Invalid adapter: invalid type for property: " +
|
|
||||||
prop);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof adapter[prop] === "function") {
|
|
||||||
wrapped[prop] = async (...args) => {
|
|
||||||
try {
|
|
||||||
return await adapter[prop](...args);
|
|
||||||
} catch (err) {
|
|
||||||
throw _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"].from(err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
wrapped[prop] = adapter[prop];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return wrapped;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function getAdapter(adapterName) {
|
|
||||||
const adapter = adapters.find((a) => a.name === adapterName);
|
|
||||||
|
|
||||||
if (!adapter) {
|
|
||||||
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"](`Unknown Adapter: ${adapterName}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return adapter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ "./src/pawsqlite_error.mjs":
|
/***/ "./src/pawsqlite_error.mjs":
|
||||||
/*!*********************************!*\
|
/*!*********************************!*\
|
||||||
!*** ./src/pawsqlite_error.mjs ***!
|
!*** ./src/pawsqlite_error.mjs ***!
|
||||||
\*********************************/
|
\*********************************/
|
||||||
/*! exports provided: PawSQLiteError */
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||||
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
__webpack_require__.r(__webpack_exports__);
|
__webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PawSQLiteError", function() { return PawSQLiteError; });
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
|
/* harmony export */ "PawSQLiteError": () => (/* binding */ PawSQLiteError)
|
||||||
|
/* harmony export */ });
|
||||||
class PawSQLiteError extends Error {
|
class PawSQLiteError extends Error {
|
||||||
static from(err) {
|
static from(err) {
|
||||||
const p_err = new PawSQLiteError(err.toString());
|
const p_err = new PawSQLiteError(err.toString());
|
||||||
@ -316,12 +193,12 @@ class PawSQLiteError extends Error {
|
|||||||
/*!************************!*\
|
/*!************************!*\
|
||||||
!*** ./src/result.mjs ***!
|
!*** ./src/result.mjs ***!
|
||||||
\************************/
|
\************************/
|
||||||
/*! exports provided: Result */
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||||
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
__webpack_require__.r(__webpack_exports__);
|
__webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Result", function() { return Result; });
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
|
/* harmony export */ "Result": () => (/* binding */ Result)
|
||||||
|
/* harmony export */ });
|
||||||
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
|
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
|
||||||
|
|
||||||
|
|
||||||
@ -349,12 +226,12 @@ class Result extends Array {
|
|||||||
/*!*****************************!*\
|
/*!*****************************!*\
|
||||||
!*** ./src/transaction.mjs ***!
|
!*** ./src/transaction.mjs ***!
|
||||||
\*****************************/
|
\*****************************/
|
||||||
/*! exports provided: Transaction */
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||||
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
__webpack_require__.r(__webpack_exports__);
|
__webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Transaction", function() { return Transaction; });
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
|
/* harmony export */ "Transaction": () => (/* binding */ Transaction)
|
||||||
|
/* harmony export */ });
|
||||||
/* harmony import */ var _result_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./result.mjs */ "./src/result.mjs");
|
/* harmony import */ var _result_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./result.mjs */ "./src/result.mjs");
|
||||||
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
|
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
|
||||||
|
|
||||||
@ -377,7 +254,7 @@ class Transaction {
|
|||||||
|
|
||||||
async sql(sql, ...args) {
|
async sql(sql, ...args) {
|
||||||
if (this._finalized) {
|
if (this._finalized) {
|
||||||
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]("Transaction has already completed");
|
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__.PawSQLiteError("Transaction has already completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._ready) {
|
if (!this._ready) {
|
||||||
@ -405,7 +282,7 @@ class Transaction {
|
|||||||
.filter(Array.isArray)
|
.filter(Array.isArray)
|
||||||
.map((a) => a.length);
|
.map((a) => a.length);
|
||||||
if (parts.length !== subParamLengths.length + 1) {
|
if (parts.length !== subParamLengths.length + 1) {
|
||||||
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]("Unable to build query: sub-" +
|
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__.PawSQLiteError("Unable to build query: sub-" +
|
||||||
"paramters do not match sub-paramters in query");
|
"paramters do not match sub-paramters in query");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,14 +328,14 @@ class Transaction {
|
|||||||
const match = reg.exec(sql);
|
const match = reg.exec(sql);
|
||||||
if (match) {
|
if (match) {
|
||||||
const statement = match[1].toUpperCase();
|
const statement = match[1].toUpperCase();
|
||||||
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]("Manually managing transactions is " +
|
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__.PawSQLiteError("Manually managing transactions is " +
|
||||||
"forbidden. Found: \"" + statement + "\" statement.");
|
"forbidden. Found: \"" + statement + "\" statement.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await this.adapter.sql(this.dbName,
|
const result = await this.adapter.sql(this.dbName,
|
||||||
...this.buildQuery(sql, ...args));
|
...this.buildQuery(sql, ...args));
|
||||||
|
|
||||||
return new _result_mjs__WEBPACK_IMPORTED_MODULE_0__["Result"](result);
|
return new _result_mjs__WEBPACK_IMPORTED_MODULE_0__.Result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _begin() {
|
async _begin() {
|
||||||
@ -467,7 +344,7 @@ class Transaction {
|
|||||||
|
|
||||||
async _complete(sql) {
|
async _complete(sql) {
|
||||||
if (this._finalized) {
|
if (this._finalized) {
|
||||||
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]("Transaction has already completed");
|
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__.PawSQLiteError("Transaction has already completed");
|
||||||
}
|
}
|
||||||
this._finalized = true;
|
this._finalized = true;
|
||||||
|
|
||||||
@ -492,7 +369,7 @@ class Transaction {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new _result_mjs__WEBPACK_IMPORTED_MODULE_0__["Result"](result);
|
return new _result_mjs__WEBPACK_IMPORTED_MODULE_0__.Result(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,12 +379,12 @@ class Transaction {
|
|||||||
/*!*************************************!*\
|
/*!*************************************!*\
|
||||||
!*** ./src/transaction_manager.mjs ***!
|
!*** ./src/transaction_manager.mjs ***!
|
||||||
\*************************************/
|
\*************************************/
|
||||||
/*! exports provided: TransactionManager */
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||||
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
__webpack_require__.r(__webpack_exports__);
|
__webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransactionManager", function() { return TransactionManager; });
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
|
/* harmony export */ "TransactionManager": () => (/* binding */ TransactionManager)
|
||||||
|
/* harmony export */ });
|
||||||
/* harmony import */ var _transaction_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./transaction.mjs */ "./src/transaction.mjs");
|
/* harmony import */ var _transaction_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./transaction.mjs */ "./src/transaction.mjs");
|
||||||
|
|
||||||
|
|
||||||
@ -520,7 +397,7 @@ class TransactionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
transaction() {
|
transaction() {
|
||||||
return new _transaction_mjs__WEBPACK_IMPORTED_MODULE_0__["Transaction"](this.dbName, this.adapter,
|
return new _transaction_mjs__WEBPACK_IMPORTED_MODULE_0__.Transaction(this.dbName, this.adapter,
|
||||||
this.enqueue.bind(this));
|
this.enqueue.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,5 +444,125 @@ class TransactionManager {
|
|||||||
|
|
||||||
/***/ })
|
/***/ })
|
||||||
|
|
||||||
/******/ })["default"];
|
/******/ });
|
||||||
|
/************************************************************************/
|
||||||
|
/******/ // The module cache
|
||||||
|
/******/ var __webpack_module_cache__ = {};
|
||||||
|
/******/
|
||||||
|
/******/ // The require function
|
||||||
|
/******/ function __webpack_require__(moduleId) {
|
||||||
|
/******/ // Check if module is in cache
|
||||||
|
/******/ if(__webpack_module_cache__[moduleId]) {
|
||||||
|
/******/ return __webpack_module_cache__[moduleId].exports;
|
||||||
|
/******/ }
|
||||||
|
/******/ // Create a new module (and put it into the cache)
|
||||||
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
||||||
|
/******/ // no module.id needed
|
||||||
|
/******/ // no module.loaded needed
|
||||||
|
/******/ exports: {}
|
||||||
|
/******/ };
|
||||||
|
/******/
|
||||||
|
/******/ // Execute the module function
|
||||||
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
||||||
|
/******/
|
||||||
|
/******/ // Return the exports of the module
|
||||||
|
/******/ return module.exports;
|
||||||
|
/******/ }
|
||||||
|
/******/
|
||||||
|
/************************************************************************/
|
||||||
|
/******/ /* webpack/runtime/define property getters */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ // define getter functions for harmony exports
|
||||||
|
/******/ __webpack_require__.d = (exports, definition) => {
|
||||||
|
/******/ for(var key in definition) {
|
||||||
|
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
||||||
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
||||||
|
/******/ }
|
||||||
|
/******/ }
|
||||||
|
/******/ };
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/make namespace object */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ // define __esModule on exports
|
||||||
|
/******/ __webpack_require__.r = (exports) => {
|
||||||
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||||
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||||
|
/******/ }
|
||||||
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
/******/ };
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
|
/************************************************************************/
|
||||||
|
var __webpack_exports__ = {};
|
||||||
|
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
||||||
|
(() => {
|
||||||
|
/*!***************************!*\
|
||||||
|
!*** ./src/pawsqlite.mjs ***!
|
||||||
|
\***************************/
|
||||||
|
__webpack_require__.r(__webpack_exports__);
|
||||||
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||||||
|
/* harmony export */ });
|
||||||
|
/* harmony import */ var _database_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database.mjs */ "./src/database.mjs");
|
||||||
|
/* harmony import */ var _adapter_wrapper_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./adapter_wrapper.mjs */ "./src/adapter_wrapper.mjs");
|
||||||
|
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
|
||||||
|
/* harmony import */ var _log_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./log.mjs */ "./src/log.mjs");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const adapters = [];
|
||||||
|
|
||||||
|
|
||||||
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
|
||||||
|
open: async function(dbName, options = {}) {
|
||||||
|
const adapter = getAdapter(options.adapter);
|
||||||
|
|
||||||
|
let db = new _database_mjs__WEBPACK_IMPORTED_MODULE_0__.Database(dbName, adapter);
|
||||||
|
await db.open();
|
||||||
|
return db;
|
||||||
|
},
|
||||||
|
delete: function(dbName, options = {}) {
|
||||||
|
const adapter = getAdapter(options.adapter);
|
||||||
|
|
||||||
|
return adapter.delete(dbName);
|
||||||
|
},
|
||||||
|
registerAdapter: function(adapter) {
|
||||||
|
const wrapped = (0,_adapter_wrapper_mjs__WEBPACK_IMPORTED_MODULE_1__.wrapAdapter)(adapter);
|
||||||
|
|
||||||
|
if (getAdapter(wrapped.name)) {
|
||||||
|
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_2__.PawSQLiteError(`An adapter with the name: ${ wrapped.name } ` +
|
||||||
|
`Already exists`);
|
||||||
|
}
|
||||||
|
|
||||||
|
adapters.push(wrapped);
|
||||||
|
},
|
||||||
|
debug: _log_mjs__WEBPACK_IMPORTED_MODULE_3__.enableDebug,
|
||||||
|
Error: _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_2__.PawSQLiteError
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function getAdapter(adapterName, silent=false) {
|
||||||
|
const adapter = adapters.find((a) => a.name === adapterName);
|
||||||
|
|
||||||
|
if (!(silent || adapter)) {
|
||||||
|
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_2__.PawSQLiteError(`Unknown Adapter: ${adapterName}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return adapter;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
module.exports = __webpack_exports__.default;
|
||||||
|
/******/ })()
|
||||||
|
;
|
||||||
//# sourceMappingURL=pawsqlite.js.map
|
//# sourceMappingURL=pawsqlite.js.map
|
File diff suppressed because one or more lines are too long
3698
package-lock.json
generated
3698
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@
|
|||||||
"author": "Ben Ashton",
|
"author": "Ben Ashton",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"webpack": "^4.44.1",
|
"webpack": "5.x",
|
||||||
"webpack-cli": "^3.3.12"
|
"webpack-cli": "4.x"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ export default {
|
|||||||
registerAdapter: function(adapter) {
|
registerAdapter: function(adapter) {
|
||||||
const wrapped = wrapAdapter(adapter);
|
const wrapped = wrapAdapter(adapter);
|
||||||
|
|
||||||
if (getAdapter(wrapped.name)) {
|
if (getAdapter(wrapped.name, true)) {
|
||||||
throw new PawSQLiteError(`An adapter with the name: ${ wrapped.name } ` +
|
throw new PawSQLiteError(`An adapter with the name: ${ wrapped.name } ` +
|
||||||
`Already exists`);
|
`Already exists`);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ var config = {
|
|||||||
output: {
|
output: {
|
||||||
path: __dirname + '/lib',
|
path: __dirname + '/lib',
|
||||||
filename: outputFile,
|
filename: outputFile,
|
||||||
library: libraryName,
|
|
||||||
libraryExport: 'default',
|
libraryExport: 'default',
|
||||||
libraryTarget: 'commonjs2',
|
libraryTarget: 'commonjs2',
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user