Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test("Issue #30 - Problem with existing db", (assert) => {
let done = assert.async();
if (!supports("compound+multiEntry")) {
ok(true, "SKIPPED - COMPOUND + MULTIENTRY UNSUPPORTED");
return done();
}
///<var type="Dexie">
var db; // Will be used as a migrated version of the db.
// Start by deleting the db if it exists:
Dexie.delete("raw-db").then(function () {
// Create a bare-bone indexedDB database with custom indexes of various kinds.
return new Dexie.Promise(function (resolve, reject) {
var indexedDB = Dexie.dependencies.indexedDB;
var rawdb, req;
function error(e) {
if (rawdb) rawdb.close();
reject(e.target.error);
}
req = indexedDB.open("raw-db", 2);
req.onupgradeneeded = function (ev) {
try {
console.log("onupgradeneeded called");
rawdb = req.result;</var>
// This special treatment in the unit tests may not need to be here if we can work around Dexie issue #1.
deepEqual(idbNames,
expected,
"IDB object stores must match expected.");
}
}
function checkTransactionObjectStores(t, expected) {
// Add baseTables.
expected = expected.concat(baseTables).sort();
deepEqual(t.storeNames.slice().sort(),
expected,
"Transaction stores must match expected.");
}
Dexie.delete(DBNAME).then(() => {
// --------------------------------------------------------------------
// Test: Empty schema
db = new Dexie(DBNAME);
db.version(1).stores({});
return db.open().then(() => {
ok(true, "Could create empty database without any schema");
// Set so add-on tables don't invalidate checks.
baseNumberOfTables = db.tables.length;
baseTables = db.tables.map(t => t.name);
});
}).then(() => {
db.close();
// --------------------------------------------------------------------
// Test: Adding version.
db = new Dexie(DBNAME);
db.version(1).stores({});
}).then(function(result) {
equal(result, true, "Should still exist");
return Dexie.delete("TestDB");
}).then(function () {
return Dexie.exists("TestDB");
}).finally(function () {
if (db) db.close();
Dexie.delete("raw-db").then(done);
});
});
teardown: function () {
stop(); Dexie.delete("TestDB").then(start);
}
});
static async clearAll(project) {
const task = ForegroundTask.start({taskTitle: 'Delete game data cache:'});
task.progress(0, 1, 'Truncating databases...');
this.db = {};
console.log(this.projectToDbName(project));
await Dexie.delete(this.projectToDbName(project));
task.finish();
}
export const provideTemporaryAndNonPersistentEngine = async (storeName: string): Promise => {
await Dexie.delete('/sqleet');
const encryptionKey = await saveRandomEncryptionKey();
const engine = new SQLeetEngine('/worker/sqleet-worker.js', SQLeetSchemata.getLatest(), encryptionKey);
await engine.init(storeName);
return engine;
};
function doRedirect(signOutReason) {
let url = `/auth/${location.search}`;
const isImmediateSignOutReason = App.CONFIG.SIGN_OUT_REASONS.IMMEDIATE.includes(signOutReason);
if (isImmediateSignOutReason) {
url = appendParameter(url, `${URLParameter.REASON}=${signOutReason}`);
}
const redirectToLogin = signOutReason !== SIGN_OUT_REASON.NOT_SIGNED_IN;
if (redirectToLogin) {
url = `${url}#login`;
}
Dexie.delete('/sqleet');
window.location.replace(url);
}
}).then(function(){
return Dexie.delete(tempName);
}).then(function () {
localStorage.setItem(name + "." + self._is_safari_10_1_upgrade_issue_fixed, true);
return this._copyDatabase(name, tempName).then(function() {
return Dexie.delete(name);
}).then(function(){
return self._copyDatabase(tempName, name);