- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个关于 JSONStore searchFields 的问题。
如果我使用 number
作为 searchFields 键并尝试通过 WL.JSONStore.find
方法以 0
作为查询来查找数据,它将命中所有数据(未过滤)。
对于上述情况的 integer
工作正常。
number
和 integer
有什么区别?
最佳答案
JSONStore 使用 SQLite 来持久化数据,您可以阅读 SQLite 数据类型 here .简短的回答是 number
将数据存储为 REAL
而 integer
将数据存储为 INTEGER
。
如果您使用一个名为 num
且类型为 number
的搜索字段创建一个名为 nums
的集合
var nums = WL.JSONStore.initCollection('nums', {num: 'number'}, {});
并添加一些数据:
var len = 5;
while (len--) {
nums.add({num: len});
}
然后使用查询调用find
:{num: 0}
nums.find({num: 0}, {onSuccess: function (res) {
console.log(JSON.stringify(res));
}})
你应该回来:
[{"_id":1,"json":{"num":4}},{"_id":2,"json":{"num":3}},{"_id":3,"json":{"num":2}},{"_id":4,"json":{"num":1}},{"_id":5,"json":{"num":0}}]
请注意,您取回了所有存储的文档(num = 4, 3, 2, 1, 0)。
如果您查看 .sqlite 文件:
$ cd ~/Library/Application Support/iPhone Simulator/6.1/Applications/[id]/Documents
$ sqlite3 jsonstore.sqlite
(android文件应该在/data/data/com.[app-name]/databases/
下)
sqlite> .schema
CREATE TABLE nums ( _id INTEGER primary key autoincrement, 'num' REAL, json BLOB, _dirty REAL default 0, _deleted INTEGER default 0, _operation TEXT);
注意 num 的数据类型是 REAL
。
运行与查找函数中使用的查询相同的查询:
sqlite> SELECT * FROM nums WHERE num LIKE '%0%';
1|4.0|{"num":4}|1363326259.80431|0|add
2|3.0|{"num":3}|1363326259.80748|0|add
3|2.0|{"num":2}|1363326259.81|0|add
4|1.0|{"num":1}|1363326259.81289|0|add
5|0.0|{"num":0}|1363326259.81519|0|add
注意 4
存储为 4.0
并且 JSONStore 的查询总是使用 LIKE
,任何带有 0
的数字都会匹配查询。
如果您改用 integer
:
var nums = WL.JSONStore.initCollection('nums', {num: 'integer'}, {});
查找返回:
[{"_id":5,"json":{"num":0}}]
schema
显示 num 具有 INTEGER
数据类型:
sqlite> .schema
CREATE TABLE nums ( _id INTEGER primary key autoincrement, 'num' INTEGER, json BLOB, _dirty REAL default 0, _deleted INTEGER default 0, _operation TEXT);
sqlite> SELECT * FROM nums WHERE num LIKE '%0%';
5|0|{"num":0}|1363326923.44466|0|add
为简洁起见,我跳过了一些 onSuccess
和所有 onFailure
回调。
关于ibm-mobilefirst - searchFields 中 'number' 和 'integer' 之间的 JSONStore 区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15423015/
是否有任何理由使用 indexed=False 设置其他字段?进入 SearchIndex ? 文档提到应该定义额外的字段来过滤或排序结果。默认 SearchIndex有 indexed=True ,
我想通过部件将数据从 2 个源传递到 Searchfield 控件,如这里的示例所示。 https://openui5.hana.ondemand.com/#/topic/dfe04650afc046
我的应用程序无法在两个(或更多)字段中进行搜索。 ESRI 的示例应用程序也存在同样的问题。 ESRI 应用程序示例:http://developers.arcgis.com/javascript/s
我有一个程序,可以从 Firebase 的云 Firestore 获取用户列表,并使用 Flutter 中的 StreamBuilder 将它们显示在 ListView 中。用户数量会很大,我想在我的
TypeError: Cannot read property 'searchField' of undefined Function.mapStateToProps [as mapToProps]
祝大家节日快乐。当我得到这个答案时我可能会觉得很傻,但我想知道如何使用 CSS "-webkit-appearance: searchfield-results-decoration"规则在搜索框内绘
我正在寻找 wtforms 的 SelectField 和 Textfield 之间的混合体,在其中可以输入一个字符串,该字符串从给定的选项列表中验证并自动完成,例如 SearchField 中的选择
我似乎无法让 SearchField 在 extJS 中工作。我想在表格工具栏中实现它,并对我的表格存储对象执行筛选。 我有这样的需求设置: Ext.require([ 'Ext.ux.for
我将这个库用于搜索文本字段 https://github.com/apasccon/SearchTextField 这是我的代码: override func viewDidLoad() {
我有一个关于 JSONStore searchFields 的问题。 如果我使用 number 作为 searchFields 键并尝试通过 WL.JSONStore.find 方法以 0 作为查询来
我有一个关于 JSONStore searchFields 的问题。 如果我使用 number 作为 searchFields 键并尝试通过 WL.JSONStore.find 方法以 0 作为查询来
因为 ExtJS 4.2 在缓冲网格(无限网格)上使用过滤器似乎有一个错误,我重写了我的代码,现在我只是使用一个简单的搜索字段让用户搜索整个网格的数据。 只要找到了一些东西,它就可以完美运行,但如果没
我是一名优秀的程序员,十分优秀!