• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript dexie.delete函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript dexie.ignoreTransaction函数代码示例发布时间:2022-05-25
下一篇:
TypeScript detect-newline.default函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap