简体   繁体   English

在千米内解析云代码查询

[英]Parse Cloud code query.withinKilometers

(Edit 1) (编辑1)

I'm trying to work with the cloud code and GeoPoint. 我正在尝试使用云代码和GeoPoint。 With the function "query.withinKilometers" I have a pointer to the Location Class but when I try to call the function I get the error "invalid key name". 使用函数“ query.withinKilometers”,我可以指向位置类,但是当我尝试调用该函数时,出现错误“无效的键名”。 What is the right way to do this? 什么是正确的方法? I could not find anything in the documentation, here is a file of the cloud function. 我在文档中找不到任何内容,这是云功能的文件。

Error: "code":105,"message":"Invalid key name: [object Object]" 错误:“代码”:105,“消息”:“无效的键名称:[对象对象]”

here de documentation: http://parseplatform.org/Parse-SDK-JS/api/v1.11.1/Parse.html 这里是文档: 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);
    }
});

You are passing an object to query.withinKilometers as the first parameter when you should be passing a String. 当您应传递字符串时,您要将对象传递给query.withinKilometers作为第一个参数。 Try using the key from your query.include call instead, like this: 尝试改为使用来自query.include调用的键,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM