Morgan Hayes Morgan Hayes - 2 months ago 5x
AngularJS Question

Query first works but find does not

I am using angularjs and
to query for three members with
spotlight = true

When i use first it will find one but when i use find with
it will find nothing. I have even removed the
and still nothing. I have searched the internet, after trying a few things i found still result is zero.

app.controller('spotlightCtrl', function($scope, $q) {

$ = {};
$scope.slmemid = "";

Parse.initialize("xxx", "xxx");
Parse.serverURL = '';
var ArticleDfd = $q.defer();
var members = Parse.Object.extend('members');
var query = new Parse.Query(members);
query.equalTo("spotlight", true);
query.first().then(function (data) {
//query.find().then(function (data) { -----this find does not return results.
}, function (error) {
.then(function (article) {
$ = article.attributes;
$scope.slmemid =;
.catch(function (error) {
//do something with the error


Still looking for a way to do this right.
I have found a work around. I use the skip() function and make three controllers.

app.controller('spotlightCtrl1', function($scope, $q) {.....
query.equalTo("spotlight", true);
query.first().then(function (data) {

app.controller('spotlightCtrl2', function($scope, $q) {......
query.equalTo("spotlight", true).skip(1);
query.first().then(function (data) {...

app.controller('spotlightCtrl3', function($scope, $q) {......
query.equalTo("spotlight", true).skip(2);
query.first().then(function (data) {....

I think this will be slower. still want to know the right code??


After searching and asking questions to Stackoverflow and I have found my own work around (all my questions received little feedback).

I used REST. There was a trickyness with the "greaterthan" (#gt) date. I the working syntax on stackoverflow. Also "Just remember to use endpoint instead of" from Davi Macedo that i came across in a search on Google Groups.

      method: 'GET',
      url: '',
      headers: {
        'X-Parse-Application-Id' : 'xxxx',
        'X-Parse-REST-API-Key' : 'xxxx',
        'Content-Type' : 'application/json'
      params:  { 
                 where: {
                     'Luncheon': true,
                     'eventDate':{'$gt': {
                     "__type":"Date", "iso": currentTime
                 order: 'eventDate',
                 limit: 2
    }).then(function successCallback(response) {
        // this callback will be called asynchronously
        // when the response is available
        $ =;

      }, function errorCallback(response) {
        // called asynchronously if an error occurs
        // or server returns response with an error status.

This has worked well and my query completely works to replace the broken find query.