如何在Parse whereWithinMiles函数中使用关系数据?

时间:2016-07-29 04:53:48

标签: java android parse-platform relational-database

我有一个Field类,它有一个指向它的指针"父亲" Venue有一个类,Venue有一个Location列,我想创建一个只带来30英里范围内的Field的查询。

query.whereWithinMiles("venueId.Location", userLocation, 30);

我确定错误出现在venueId.Location中,但我不知道如何获取指针位置列的值。

venueId是指针。 位置是我要比较的指针列。 userLocation是用户当前位置。

感谢阅读。

1 个答案:

答案 0 :(得分:2)

在查询的位置不支持点表示法,但仅在include中。 如果您愿意,您需要使用** whereMatchesKeyInQuery **

编写查询

所以在你的情况下它应该看起来像那样(根据你的类改变值):

ParseQuery query = new ParseQuery.getQuery("ParentClass");  // change the class name
ParseGeoPoint point = new ParseGeoPoint(40.712784,-74.005941);  // put your location here
query.whereWithinMiles("location",point,30);

ParseQuery venueQuery = new ParseQuery.getQuery("SubClass");  // change the class name
venueQuery.whereMatchesKeyInQuery("venueId","objectId",query);
venueQuery.findInBackground(new FindCallback() {
    @Override
    public void done(List objects, ParseException e) {

    }

    @Override
    public void done(Object o, Throwable throwable) {

    }
});