本文整理汇总了TypeScript中dexie.delete函数的典型用法代码示例。如果您正苦于以下问题:TypeScript delete函数的具体用法?TypeScript delete怎么用?TypeScript delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: promisedTest
promisedTest("simple-import", async ()=>{
const blob = new Blob([JSON.stringify(IMPORT_DATA)]);
await Dexie.delete(DATABASE_NAME);
const db = await Dexie.import(blob, {
chunkSizeBytes: 11,
});
const friends = await db.table("friends").toArray();
deepEqual(IMPORT_DATA.data.data[0].rows, friends, "Imported data should equal");
try {
await db.import(blob);
ok(false, "Should not work to reimport without overwriteValues option set");
} catch (error) {
equal(error.name, "BulkError", "Should fail with BulkError");
}
await db.import(blob, { overwriteValues: true });
const friends2 = await db.table("friends").toArray();
deepEqual(IMPORT_DATA.data.data[0].rows, friends2, "Imported data should equal");
db.close();
await Dexie.delete(DATABASE_NAME);
});
示例2: beforeAll
beforeAll(async () => {
await Dexie.delete('VcsCommitContribution');
TestBed.configureTestingModule({
providers: [VcsCommitContributionDatabaseProvider],
});
});
示例3: promisedTest
promisedTest("chunkedExport (issue #854)", async ()=>{
const blob = new Blob([JSON.stringify(IMPORT_DATA)]);
await Dexie.delete(DATABASE_NAME);
const db = await Dexie.import(blob);
const exportBlob1 = await db.export({numRowsPerChunk: 1000});
ok(true, "Could export using numRowsPerChunk: 1000");
const exportBlob2 = await db.export({numRowsPerChunk: 1});
ok(true, "Could export using numRowsPerChunk: 1");
const exportBlob3 = await db.export({numRowsPerChunk: 1, prettyJson: true});
ok(true, "Could export using numRowsPerChunk: 1 and prettyJson: true");
const json1 = await readBlob(exportBlob1);
ok(true, "Could read back first blob: " + json1);
const json2 = await readBlob(exportBlob2);
ok(true, "Could read back second blob: " + json2);
const json3 = await readBlob(exportBlob3);
ok(true, "Could read back third blob: " + json3);
const parsed1 = JSON.parse(json1);
ok(true, "Could parse first export");
const parsed2 = JSON.parse(json2);
ok(true, "Could parse second export");
const parsed3 = JSON.parse(json3);
ok(true, "Could parse third export");
const rejson1 = JSON.stringify(parsed1);
const rejson2 = JSON.stringify(parsed2);
const rejson3 = JSON.stringify(parsed3);
equal (rejson1, rejson2, "First and second exports are equal");
equal (rejson2, rejson3, "Second and third expots are equal");
});
示例4: beforeAll
beforeAll(async () => {
await Dexie.delete('VcsAccount');
TestBed.configureTestingModule({
providers: [VcsAccountDatabaseProvider],
});
});
示例5: runCars
export async function runCars() {
const idbOpts = {
databaseName: 'cars-db'
}
const dbToDelete = new Dexie(idbOpts.databaseName)
await dbToDelete.delete()
const idbStore = new IndexedDBPlugin(idbOpts, Car)
// Create a coordinator
const coordinator = new Coordinator()
// Initialize it with all plugins
await coordinator.init({
syncStrategy: SyncStrategy.Overwrite
},idbStore)
// Then start it with all models
await coordinator.start(Car)
let car1 = new Car({
manufacturer: 'volvo',
year: 1956,
model: '740gle',
tagLine: 'old school'
})
const repo1 = coordinator.getRepo(CarRepo)
car1 = await repo1.save(car1)
log.info('Car saved')
let carCount = await repo1.count()
assert(carCount === 1, 'only 1 car in there today!')
log.info('Car count = 1')
const car1Key = repo1.key(car1.manufacturer)
const car1FromRepo = await repo1.get(car1Key)
assert(car1FromRepo.manufacturer === car1.manufacturer &&
car1FromRepo.year === car1.year &&
car1FromRepo.model === car1.model
,`These should be identical\n${JSON.stringify(car1,null,4)}
from repo \n${JSON.stringify(car1FromRepo,null,4)}`)
log.info('Car models match')
await repo1.remove(car1Key)
log.info('Car removed')
carCount = await repo1.count()
assert(carCount === 0, 'only 1 car in there today!')
log.info('Car count 0')
log.info('All tests run')
return true
}