将查询条件添加到相关对象'的属性
Add Query conditionals to related object's properties in parse.com with JS SDK
是否可以对parse.com中的相关对象排序并使用条件语句?
我有一些用户,他们有一个指向profilePictures的指针。我想要一个查询,例如:
var query = new Parse.Query(Parse.User);
// include images
query.include("profilePicture");
// get only regular users
query.notEqualTo("isAdmin", true);
// who has uploaded an image
query.exists("profilePicture");
// and such image was updated in the last month
query.lessThanOrEqualTo("profilePicture.updatedAt", today);
query.greaterThanOrEqualTo("profilePicture.updatedAt", lastMonth);
// and order the resultset by profilePicture.updatedAt
query.ascending("profilePicture.updatedAt");
不幸的是,这从parse.com返回了一个105错误,因为它找不到属性。。。
{"code":105,"error":"profilePicture.updatedAt is not a valid order key"}
我发现的所有帖子都很旧(2012年),最近可能有什么变化。你知道如何做到这一点吗?
对于排序,我真的不在乎。我已经实现了一个比较器,但我需要按日期进行筛选,因为我不能免费查询1000个配置文件。
使用include
和点表示法无法实现这一点。您最好使用内部查询:
var innerQuery = new Parse.Query("PICTURES"); // query on your profile picture class
innerQuery.lessThanOrEqualTo("updatedAt", today);
innerQuery.greaterThanOrEqualTo("updatedAt", lastMonth);
var query = new Parse.Query(Parse.User);
query.matchesQuery("profilePicture", innerQuery); // users that match the picture criteria
query.find({
success: function(users) {
// You get selected users with the profilePicture criteria
}
});
相关文章:
- 为什么我可以在Array属性对象中找到Javascript Array for Each方法
- 使用onclick调用属性对象函数
- 嵌套为..in 循环,列出多维对象的属性(对象)
- 动态属性对象 - JSON
- 在不使用隔离范围angularjs自定义指令的情况下获取属性对象
- 通过属性传递属性/对象.Javascript
- Javascript:属性/对象的类型
- 访问JSON中的属性(对象)
- 属性对象Javascript不是用Jquery Deferred设置的
- 无法读取属性'#<对象>'未定义的获取错误
- Twitter中多属性对象的子字符串匹配
- 无法设置'data'属性'对象'标记.(只IE8)
- 更新数据属性对象属性值
- 将属性对象的选定对象从原型推入数组
- 将单个属性对象字面量的数组转换为仅包含其值的数组的最佳方法
- 寻找一种更简单的方法来检查是否多个属性&对象中的方法是未定义的
- 主干模型:带有get方法的空属性,但在属性对象中
- 如何赋值给"text"someText"属性对象在动能js
- Angularjs的数据绑定与数据属性对象
- 如何将一个嵌套的javascript对象转换为只有一级属性对象