有谁知道如何使用查询字符串来访问 Nanoscale.io 中的存储(集合)数据?我尝试阅读他们的文档,但唯一的示例如下:
local.request = new AP.Store.Request();
local.request.select("Tasks", "priority >= $1 order numeric(priority) asc", parseInt(request.params.priority));
我不知道“priority >= $1 order numeric(priority) asc”中的语法来自哪里...
在他们的文档中:
select(collection, query)
Selects matching objects from a collection based off of the query string.
collection [string] - Collection name.
query [string | number] - This can be either a query or a number. If a number, the operation will return the object that has a matching ID. To return all, use the string "true".
除了“true”之外,我不知道如何形成自己的查询。
最佳答案
在您提供的示例中(并在文档中提供),priority
将是您的集合中您有兴趣搜索的字段,并且 $1
是 select 函数中提供的下一个值,即 parseInt(request.params.priority)
。 request.params.priority
是查询参数“priority”的值,在本例中,为了比较,它被解析为 int。
根据我的发现,您可以进行所有基本比较( =
、 !=
、 >(=)
、 <(=)
)。
关于javascript - nanoscale.io 商店的查询语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42392789/