Jaydata WebSql Provider with Typescript

↘锁芯ラ 提交于 2019-12-11 13:27:19

问题


I've been using jaydata with TypeScript against an OData store as described here: http://jaystack.com/blog/typescript-meets-odata-with-the-help-of-jaydata-and-jaysvcutil.

Now, I'm trying to extend the application to use a local store as well (say, webSql) but it appears the typescript declaration file only allows for an OData context to be instantiated. How can I use the declaration file while targeting a different storage provider?


回答1:


I work for JayData. Sorry for the late reply. In JayData we have a "virtual" provider called 'local'. It hides the different local storage technologies the different browsers support, so you don't have to worry about it and write code for IndexedDB, WebSQL and HTML5.localStorage. Just write it once and it will work.

All you have to do is to change the parameters of the service, like this:

var mydatabaseService = new mydatabase.mydatabaseService({
    name: 'local',
    databaseName: 'myitems'
});

There are a few things to be careful about: -string primary keys are not supported (not by JayData but by the stores) -if you want navigation properties then currently it is only supported by sqLite so you must use it explicit (name: 'sqLite' instead of name: 'local') and sqlite can not be found in every device. We will implement navigation in other stores soon.




回答2:


At the risk of stating the obvious: you could create your own d.ts declaration file, or edit the one you have been using, or see if there is one here: https://github.com/borisyankov/DefinitelyTyped



来源:https://stackoverflow.com/questions/13683236/jaydata-websql-provider-with-typescript

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