本文整理汇总了TypeScript中@orbit/data.Schema.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Schema.on方法的具体用法?TypeScript Schema.on怎么用?TypeScript Schema.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@orbit/data.Schema
的用法示例。
在下文中一共展示了Schema.on方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: skip
skip('will reopen the database when the schema is upgraded', async function(assert) {
const done = assert.async();
assert.expect(5);
assert.equal(source.cache.dbVersion, 1, 'db starts with version == 1');
source.cache.migrateDB = function(db, event) {
assert.equal(
event.oldVersion,
1,
'migrateDB called with oldVersion == 1'
);
assert.equal(
event.newVersion,
2,
'migrateDB called with newVersion == 2'
);
done();
};
schema.on('upgrade', version => {
assert.equal(version, 2, 'schema has upgraded to v2');
assert.equal(source.cache.dbVersion, 2, 'db has the correct version');
});
await source.cache.openDB();
await schema.upgrade({
models: {
planet: {
attributes: {
name: { type: 'string' }
}
},
moon: {
attributes: {
name: { type: 'string' }
}
}
}
});
});