我尝试使用我从Appcelerator平台下载的模块SQLite数据库加密模块,该模块仅适用于专业座位。
我把这个加到我的模特身上
try {
require('appcelerator.encrypteddatabase');
var dbType = "enc.db";
} catch(e) {
var dbType = "sql";
}在适配器上
adapter : {
type : dbType,
collection_name : "somename",
idAttribute : "someid",
migration : "20161105200100"
}当我运行这个项目时,我会得到这个错误,因为适配器没有enc.db类型。
有人在使用这个模块时有类似的问题吗?
编辑:
钛SDK版本: 5.5.1.GA模块版本: 1.3.3
测试:iPhone5s,10.2.1模拟器,iphone 7+,10.1版
发布于 2017-02-08 19:08:50
要使用平台加密模块,我使用:
在alloy.js中
// Use encrypteddatabase if the module is included, else use sql.
try {
require('appcelerator.encrypteddatabase');
Alloy.Globals.dbEncrypted = 'enc.db';
} catch (e) {
console.error('appcelerator.encrypteddatabase module is not available', e);
}
Alloy.Globals.dbType = 'sql';在models/myModel.js中
var dbType = Alloy.Globals.dbEncrypted || Alloy.Globals.dbType || 'sql';
...
config: {
columns: {
id: 'TEXT PRIMARY KEY',
firstName: 'TEXT',
lastName: 'TEXT'
},
adapter: {
type: dbType,
collection_name: 'myModel',
idAttribute: 'id',
db_name: 'myModel.' + dbType
}
}在我的例子中,db_name是专门为这个模型生成的(因为我有加密和非加密数据库的组合,但是您也可以使用类似于db_name: 'myModel'的东西)。
Ti SDK版本5.2.2.GA和模块版本1.1.4
我这边一切都很好。
https://stackoverflow.com/questions/41994256
复制相似问题