当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Coordinator.init方法代码示例

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


在下文中一共展示了Coordinator.init方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: reset

/**
 * Reset TypeStore and start all over
 *
 * @param syncStrategy
 * @param endpoint
 * @returns {Bluebird<Coordinator>}
 */
async function reset(syncStrategy:SyncStrategy,endpoint:string) {
	// Init dynamo type
	// using local


	const opts:IDynamoDBStorePluginOptions = {
		endpoint: endpoint,
		prefix: `test_${process.env.USER}_`
	}

	store = new DynamoDBStorePlugin(opts,Fixtures.Test1)

	if (!endpoint)
		delete opts['endpoint']


	if (coordinator)
		await coordinator.stop()

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

示例6: runCars

export async function runCars() {


	let dynamoEndpoint = DynamoDBLocalEndpoint
	let dynamoLocal = null, dynamoPort = 8787

	if (process.env.CIRCLE) {
		dynamoLocal = require('dynamodb-local')
		await dynamoLocal.launch(dynamoPort, null, ['-sharedDb'])
		dynamoEndpoint = `http://localhost:${dynamoPort}`
	}



	// Pass in options and the indexer/search
	// will service as a rest array
	const cloudSearchProvider = new CloudSearchProviderPlugin({
		endpoint: CloudSearchLocalEndpoint,
		awsOptions: {
			region: 'us-east-1',
			credentials:awsCredentialChain
		}
	},Car)

	// Pass in options and the models that the store
	// will service as a rest array
	const dynamoStore = new DynamoDBStorePlugin({
		endpoint: dynamoEndpoint,
		prefix: `examples_cars_${process.env.USER}_`
	},Car)


	// Create a coordinator
	const coordinator = new Coordinator()

	// Initialize it with all plugins
	await coordinator.init({
		syncStrategy: SyncStrategy.Overwrite
	},dynamoStore,cloudSearchProvider)

	// 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)

	let carCount = await repo1.count()
	assert.ok(carCount === 1, 'only 1 car in there today!')

	const car1Key = repo1.key(car1.manufacturer,car1.year)
	const car1FromRepo = await repo1.get(car1Key)

	assert.ok(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)}`)

	await repo1.remove(car1Key)
	carCount = await repo1.count()
	assert.ok(carCount === 0, 'only 1 car in there today!')

	if (dynamoLocal)
		await dynamoLocal.stop(dynamoPort)

	return true
}
开发者ID:densebrain,项目名称:typestore,代码行数:74,代码来源:ExampleRunCarsNode.ts


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