解析云代码查询.ininKilometers

时间:2018-05-19 18:16:31

标签: javascript parse-platform parse-cloud

(编辑1)

我正在尝试使用云代码和GeoPoint。使用函数“query.withinKilometers”我有一个指向Location Class的指针,但是当我尝试调用该函数时,我得到错误“无效的键名”。这样做的正确方法是什么?我在文档中找不到任何内容,这里是云函数的文件。

错误:“code”:105,“message”:“无效的键名:[object Object]”

此处是文档:http://parseplatform.org/Parse-SDK-JS/api/v1.11.1/Parse.html

Parse.Cloud.define("getCloseFindings", function(request, response){
var query           = new Parse.Query("findings");
var locQuery        = query.include("location");
var LocQuery        = locQuery.get("geoLocation");
var Loc_Lat         = request.params.Latitude;
var Loc_Long        = request.params.Longitude;
var UserLocation    = new Parse.GeoPoint(Loc_Lat,Loc_Long);
var RadiusLocation  = request.params.Radius;

query.equalTo("isDeleted", false);
query.withinKilometers(locQuery, UserLocation, 100);
query.find({
    success: function(results){
        if(results === undefined){
            var response_jsonArr = {
                code : 404,
                message : "Not Found"
            };
            response.success(response_jsonArr);
        }else{
            var jsonArr = [];
            for ( var i = 0; i < results.length; ++i ) {
                var finding_location    = results[i].get("location");
                jsonArr.push({
                    name: results
                });
            }
            response.success(jsonArr);
        }
    }, error: function(error){
        response.error(error);
    }
});

1 个答案:

答案 0 :(得分:2)

当您传递String时,您将对象传递给query.withinKilometers作为第一个参数。请尝试使用query.include调用中的密钥,如下所示:

query.withinKilometers("location", userLocation, 100);