本文整理汇总了TypeScript中typestore.Coordinator.start方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Coordinator.start方法的具体用法?TypeScript Coordinator.start怎么用?TypeScript Coordinator.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typestore.Coordinator
的用法示例。
在下文中一共展示了Coordinator.start方法的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
}
示例2: before
before(async () => {
if (coordinator)
await coordinator.stop()
coordinator = new Coordinator()
await coordinator.init({},store,cloudSearchProvider)
await coordinator.start(CloudSearchTestModel)
})
示例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
}
示例4: before
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)
})
示例5: it
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')
})
示例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
}
示例7: before
before(async () => {
await reset()
await coordinator.start(Fixtures.IDBModel1)
return true
})