2019-01-16 18:57:07 +00:00
|
|
|
export const fieldGenerator = self => (column, name) => {
|
|
|
|
Object.defineProperty(self, name || column, {
|
|
|
|
get() { return self._getRaw(column) },
|
|
|
|
set(value) { self._setRaw(column, value) },
|
|
|
|
enumerable: true,
|
|
|
|
configurable: true
|
|
|
|
})
|
|
|
|
}
|
2019-01-17 17:16:17 +00:00
|
|
|
|
|
|
|
export function initialize(target, name, descriptor) {
|
|
|
|
descriptor.initializer = true
|
|
|
|
}
|
2019-03-07 21:05:48 +00:00
|
|
|
|
|
|
|
export function databaseExists(name){
|
|
|
|
return new Promise(function(resolve, reject){
|
|
|
|
var db = indexedDB,
|
|
|
|
req;
|
|
|
|
|
|
|
|
try{
|
|
|
|
// See if it exist
|
|
|
|
req = db.webkitGetDatabaseNames();
|
|
|
|
req.onsuccess = function(evt){
|
|
|
|
~([].slice.call(evt.target.result)).indexOf(name) ?
|
|
|
|
resolve(true):
|
|
|
|
reject(false);
|
|
|
|
}
|
|
|
|
} catch (e){
|
|
|
|
// Try if it exist
|
|
|
|
req = db.open(name);
|
|
|
|
req.onsuccess = function () {
|
|
|
|
req.result.close();
|
|
|
|
resolve(true);
|
|
|
|
}
|
|
|
|
req.onupgradeneeded = function (evt) {
|
|
|
|
evt.target.transaction.abort();
|
|
|
|
reject(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|