Parse.Query find()方法没有返回任何东西

时间:2015-02-13 07:59:11

标签: javascript angularjs parse-platform

我已经回顾了关于这个主题的其他堆栈溢出帖子,看起来我已经碰到了新的东西。有问题的查询方法不在用户表上。

当我查询mBuilding对象中的距离或许多其他列时,我得到了未定义,即使列清楚地存在,我将列标题复制并粘贴到函数中以检查拼写。从我所看到的,唯一有效的查询是通过objectId获取并查找。 equalTo,select,withinMiles(至少)返回null / undefined结果。更有趣的是,即使find()之前的查询未定义,它也会适当地影响查找结果。这真是令人困惑。

这里发生了什么?我的代码:

angular.module('startupApp')
.controller('warrantyCtrl', function ($scope) {
    $scope.Building = {};

    $scope.Building.parseUserId = Parse.User.current().id;
    console.log($scope.Building.parseUserId);
    var consumer = Parse.User.current();
    var user = Parse.Object.extend("User");
    var warrantys = Parse.Object.extend("warranty");
    var mBuilding = new Parse.Query(warrantys);
    var consumerQuery = new Parse.Query(Parse.User);

    $scope.consumerBuilding = function() {
        var location = consumer.get("location");
        mBuilding.withinMiles("location", location, "distance");
        mBuilding.find({
            success: function (proximalwarrantys){
                console.log(proximalwarrantys);
            }
        })
    }
    $scope.consumerBuilding();

});

1 个答案:

答案 0 :(得分:1)

问题是传递给withinMiles函数的距离应该是一个数字,而不是"distance"

withinMiles(key, point, maxDistance)

  

添加基于邻近度的约束   用于查找具有接近给定点的关键点值的对象   在给定的最大距离内。使用的地球半径为3958.8   英里。

     

参数:

     

{String} key   Parse.GeoPoint的关键   存储在。

     

{Parse.GeoPoint} point   参考Parse.GeoPoint即   用过的。

     

{Number} maxDistance   结果的最大距离(以英里为单位)   返回。返回:

     

{Parse.Query}返回查询,以便链接   这个电话。

Parse API Docs

相关问题