Compare commits
No commits in common. "d97c12cd3f6197a8a006c9349cdd142197fb91fa" and "1adcaa2e224ce96e244343b83837fa8b9bac9e24" have entirely different histories.
d97c12cd3f
...
1adcaa2e22
27
src/adapters/cordova_pawsqlite/psql_adapter.mjs
Normal file
27
src/adapters/cordova_pawsqlite/psql_adapter.mjs
Normal file
@ -0,0 +1,27 @@
|
||||
import { PSQLAdapterError } from "./psql_adapter_error.mjs";
|
||||
import { log } from "../../log.mjs";
|
||||
|
||||
|
||||
export const PSQLAdapter = {
|
||||
open: (dbName) => new Promise((resolve, reject) => {
|
||||
cordova.exec(resolve, (e) => {
|
||||
reject(new PSQLAdapterError(e));
|
||||
}, "PawSQLite", "open", [dbName]);
|
||||
}),
|
||||
close: (dbName) => new Promise((resolve, reject) => {
|
||||
cordova.exec(resolve, (e) => {
|
||||
reject(new PSQLAdapterError(e));
|
||||
}, "PawSQLite", "close", [dbName]);
|
||||
}),
|
||||
sql: (dbName, sql, ...args) => new Promise((resolve, reject) => {
|
||||
log(sql);
|
||||
cordova.exec(resolve, (e) => {
|
||||
reject(new PSQLAdapterError(e));
|
||||
}, "PawSQLite", "sql", [dbName, sql, ...args]);
|
||||
}),
|
||||
delete: (dbName) => new Promise((resolve, reject) => {
|
||||
cordova.exec(resolve, (e) => {
|
||||
reject(new PSQLAdapterError(e));
|
||||
}, "PawSQLite", "delete", [dbName]);
|
||||
})
|
||||
};
|
31
src/adapters/cordova_pawsqlite/psql_adapter_error.mjs
Normal file
31
src/adapters/cordova_pawsqlite/psql_adapter_error.mjs
Normal file
@ -0,0 +1,31 @@
|
||||
import { PawSQLiteError } from "../../pawsqlite_error.mjs";
|
||||
|
||||
|
||||
export class PSQLAdapterError extends PawSQLiteError {
|
||||
constructor(response) {
|
||||
if (response.hasOwnProperty("message")) {
|
||||
super(response.message);
|
||||
} else {
|
||||
super();
|
||||
}
|
||||
if (response.hasOwnProperty("name")) {
|
||||
this.name = response.name;
|
||||
} else {
|
||||
this.name = "PSQLAdapterError";
|
||||
}
|
||||
if (response.hasOwnProperty("trace")) {
|
||||
this.trace = response.trace;
|
||||
}
|
||||
}
|
||||
|
||||
toString() {
|
||||
let str = this.name;
|
||||
if (this.hasOwnProperty("message")) {
|
||||
str += ": " + this.message;
|
||||
}
|
||||
if (this.hasOwnProperty("trace")) {
|
||||
str += "\n" + this.trace;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
@ -21,10 +21,6 @@ export default {
|
||||
return adapter.delete(dbName);
|
||||
},
|
||||
registerAdapter: function(adapter) {
|
||||
if (!adapter) {
|
||||
throw new PawSQLiteError("Invalid adapter");
|
||||
}
|
||||
|
||||
const wrapped = wrapAdapter(adapter);
|
||||
|
||||
if (getAdapter(wrapped.name, true)) {
|
||||
|
Loading…
Reference in New Issue
Block a user