JayData : how to migrate code from v1.3 to v1.5

余生颓废 提交于 2019-12-11 02:06:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!