问题
I have some code which worked in JayData 1.3.
I need to upgrade JayData to 1.5 due to the compatibility issues the 1.3 version has with polymer.
The upgrade instructions say you can use the "jaydata-compatibility.js
" script to "upgrade your app to JayData 1.5.x from previous versions step-by-step", however when I add that in as described I simply get the error, "typeOrName requires a value other than undefined or null
", which actually doesn't help me step through the upgrade at all.
Here is the JayData 1.3 code :
$data.Entity.extend('Cache', {
'id': { 'type': 'int', 'key': true, 'computed': true },
'url': { 'type': 'string' },
'method': { 'type': 'string', 'required': true },
'dts': { 'type': 'string', 'required': true },
'encryptMeth': { 'type': 'string' },
'data': { 'type': 'string' }
});
$data.EntityContext.extend('APIWrapperDB', {
'Cache': { 'type': $data.EntitySet, 'elementType': Cache }
});
var cacheDatabase = new APIWrapperDB('TheAPIWrapperDatabase');
cacheDatabase.onReady( function() { /* now my DB is ready */ };
What is the JayData 1.5 equalivalent of this code?
回答1:
This is the updated snippet, I've just declared your entity definitions as variables as JayData stopped using global objects.
var Cache = data.Entity.extend('Cache', {
'id': { 'type': 'int', 'key': true, 'computed': true },
'url': { 'type': 'string' },
'method': { 'type': 'string', 'required': true },
'dts': { 'type': 'string', 'required': true },
'encryptMeth': { 'type': 'string' },
'data': { 'type': 'string' }
});
var APIWrapperDB = $data.EntityContext.extend('APIWrapperDB', {
'Cache': { 'type': $data.EntitySet, 'elementType': Cache }
});
var cacheDatabase = new APIWrapperDB('TheAPIWrapperDatabase');
cacheDatabase.onReady( function() { /* now my DB is ready */ };
来源:https://stackoverflow.com/questions/41884051/jaydata-how-to-migrate-code-from-v1-3-to-v1-5