本文整理汇总了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);
});
开发者ID:dfahlander,项目名称:Dexie.js,代码行数:25,代码来源:basic-tests.ts
示例2: beforeAll
beforeAll(async () => {
await Dexie.delete('VcsCommitContribution');
TestBed.configureTestingModule({
providers: [VcsCommitContributionDatabaseProvider],
});
});
开发者ID:suiruiw,项目名称:geeks-diary,代码行数:7,代码来源:vcs-commit-contribution-database.spec.ts
示例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");
});
开发者ID:dfahlander,项目名称:Dexie.js,代码行数:28,代码来源:edge-cases.ts
示例4: beforeAll
beforeAll(async () => {
await Dexie.delete('VcsAccount');
TestBed.configureTestingModule({
providers: [VcsAccountDatabaseProvider],
});
});
开发者ID:suiruiw,项目名称:geeks-diary,代码行数:7,代码来源:vcs-account-database.spec.ts
示例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
}
开发者ID:densebrain,项目名称:typestore,代码行数:58,代码来源:ExampleRunCarsWebPack.ts
注:本文中的dexie.delete函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论