Search code examples
javascriptparse-platform

Retrieve all objects that have a column that does not equal to undefined


enter image description here
I want to retrieve two objects with title cc and bb above.
My code:

var Item = Parse.Object.extend('Item');
var query = new Parse.Query(Item);
query.notEqualTo('parentItem',undefined);
query.find().then(function(subItems){
    console.log(subItems);
},function(error){
    console.log(error.code+': '+error.message);
});

The error is 102: pointer field parentItem needs a pointer value
Any help is really appreciate.


Solution

  • Use Parse.Query.exists(key)

    var Item = Parse.Object.extend('Item');
    var query = new Parse.Query(Item);
    query.exists('parentItem');
    query.find().then(function(subItems){
       console.log(subItems);
    },function(error){
       console.log(`${error.code}: ${error.message}`;
    });