Worklight v6:在app中同时使用多个JSON存储 [英] Worklight v6: use multiple JSON stores concurrently in app

查看:191
本文介绍了Worklight v6:在app中同时使用多个JSON存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以同时在Worklight应用中使用两个或更多JSON存储(无需来回切换)?当我使用用户名/密码初始化第二个JSON存储时,正确初始化的默认JSON存储中的集合变得不可访问。

Is it possible to use two or more JSON stores in a Worklight app at the same time (without switching back and forth)? When I initialize a second JSON store with a username/password, collections in the "default" JSON store that were initialized properly become inaccessible.

鉴于JSON中的许多函数store api不允许你指定目标商店,我猜测同时使用多个商店是不可能的。如果这是真的,那么如何解决有必要的用例:

Given that many functions in the JSON store api does not let you specify a target store, I am guessing that using multiple stores concurrently is not possible. If this is true, then how does one address the use case where it is necessary to:


  1. 加密敏感用户数据,

  2. 在用户通过身份验证之前,需要访问非敏感数据。


推荐答案

传递给init的用户名字段基本上是商店的文件名,示例:

The username field you pass to init is basically the file name for the store, for example:

WL.JSONStore.init(...,{username:'store1'})

您将在磁盘上安装store1.sqlite,不加密。如果您想切换到另一家商店,只需致电:

You will have store1.sqlite on disk, no encryption. If you want to switch to another store simply call:

WL.JSONStore.closeAll()

closeAll函数将终止所有数据库访问器。然后你可以用密码开始第二个商店,例如:

The closeAll function will kill all database accessors. Then you can start a second store with a password, for example:

WL.JSONStore.init(...,{username:'store2 ',密码:'123'})

这将创建一个使用256位AES加密加密的store2.sqlite文件。

That will create a store2.sqlite file encrypted with 256-bit AES encryption.

如果要切换回store1,只需调用 WL.JSONStore.closeAll()然后 WL.JSONStore.init(...,{username:'store1'})

If you want to switch back to store1, simply call WL.JSONStore.closeAll() and then WL.JSONStore.init(..., {username: 'store1'}).

目前您无法访问store1和store2与此同时。您可以打开功能请求此处

Currently you can not access store1 and store2 at the same time. You can open a feature request here.

提到了.sqlite文件这里如果你想在文件系统上看到它们,并提到它们的一些内部结构此处 。上面的代码片段没有显示它,但请确保您考虑到大多数JSONStore API函数都是异步的,请阅读更多这里

The .sqlite files are mentioned here if you want to see them on the file system, and a bit of their internal structure is mentioned here. The code snippets above don't show it, but make sure you take into account that most JSONStore API functions are async, read more here.

这篇关于Worklight v6:在app中同时使用多个JSON存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆