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

TypeScript typestore.Coordinator类代码示例

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

本文整理汇总了TypeScript中typestore.Coordinator的典型用法代码示例。如果您正苦于以下问题:TypeScript Coordinator类的具体用法?TypeScript Coordinator怎么用?TypeScript Coordinator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Coordinator类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: reset

/**
 * Reset TypeStore and start all over
 */
async function reset(useGlobal = true, extraOpts = null,...models) {
	
	await stop()
	
	const
		storeOpts:IPouchDBOptions = Object.assign({
			//filename: `test-db.websql.db`,
			//sync: true
			//filename: `http://127.0.0.1:5984/tstest-${new Date()}`
			filename: `/tmp/tstest-${Date.now()}`,
			databasePerRepo: !useGlobal
		},extraOpts || {})
	
	//if (!useGlobal)
	//mkdirp(storeOpts.filename)
	
	log.info(`Create store - global = ${useGlobal}`)
	store = new PouchDBPlugin(storeOpts)
	
	coordinator = new Coordinator()
	log.info(`Init coordinator`)
	await coordinator.init({}, store)
	
	log.info(`Start coordinator`)
	await coordinator.start(...models)
	return coordinator
}
开发者ID:densebrain,项目名称:typestore,代码行数:30,代码来源:PouchDBPlugin.spec.ts


示例2: before

	before(async () => {
		if (coordinator)
			await coordinator.stop()

		coordinator = new Coordinator()
		await coordinator.init({},store,cloudSearchProvider)
		await coordinator.start(CloudSearchTestModel)
	})
开发者ID:densebrain,项目名称:typestore,代码行数:8,代码来源:CloudSearchProvider.spec.ts


示例3: 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


示例4: reset

/**
 * Reset TypeStore and start all over
 *
 * @returns {Bluebird<Coordinator>}
 */
async function reset() {
	// Init dynamo type
	// using local
	store = new IndexedDBPlugin(storeOpts)

	if (coordinator)
		await coordinator.reset()

	coordinator = new Coordinator()
	await coordinator.init({},store)
	return coordinator
}
开发者ID:densebrain,项目名称:typestore,代码行数:17,代码来源:IndexedDBPlugin.spec.ts


示例5: uuid

		before(async () => {
			t1 = new Fixtures.Test1()
			t1.id = uuid()
			t1.createdAt = new Date().getTime()
			t1.randomText = 'asdfasdfadsf'

			await coordinator.start(Fixtures.Test1)
			test1Repo = coordinator.getRepo(Fixtures.Test1Repo)
		})
开发者ID:densebrain,项目名称:typestore,代码行数:9,代码来源:DynamoDBStore.spec.ts


示例6: async

	it('#tableDef', async () => {
		await coordinator.start(Fixtures.Test1)

		const modelOpts = coordinator.getModel(Fixtures.Test1)
		const tableDef = store.tableDefinition(modelOpts.name)

		expect(tableDef.KeySchema.length).toBe(2)
		expect(tableDef.AttributeDefinitions.length).toBe(3)
		expect(tableDef.AttributeDefinitions[0].AttributeName).toBe('id')
		expect(tableDef.AttributeDefinitions[0].AttributeType).toBe('S')
	})
开发者ID:densebrain,项目名称:typestore,代码行数:11,代码来源:DynamoDBStore.spec.ts


示例7: async

				doTest = async (modelClazz,repoClazz) => {
					try {
						let
							model = new modelClazz(),
							repo = coordinator.getRepo(repoClazz)
						
						Object.assign(model, {
							id: uuid.v4(),
							createdAt: Faker.date.past(),
							randomText: Faker.lorem.words(10)
						})
						
						model = await repo.save(model)
						
						const
							model2 = Object.assign(new modelClazz(),model, {
								randomText: Faker.lorem.words(10),
								$$doc: Object.assign({},(model as any).$$doc,{
									_rev: '1-aa86c0e405a07fb76ef3e523dd1c2ae1'
								}),
							})
						
						await repo.save(model2)
						
						return null
					} catch (anErr) {
						return anErr
						
					}
				}
开发者ID:densebrain,项目名称:typestore,代码行数:30,代码来源:PouchDBPlugin.spec.ts



注:本文中的typestore.Coordinator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript typestore.Log类代码示例发布时间:2022-05-25
下一篇:
TypeScript typestore.FinderDescriptor函数代码示例发布时间: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