當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript dexie.delete函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。