2
votes

i am trying to query a class of users which contains a relation column called "blocking" which contains a list of user objects from the same class

when i try to query all users i would like to query which is not present in this relation column

i did the following

var currentUser = Parse.User.current();
var relation = currentUser.relation('blocking')
query.doesNotExist(relation);
query.find().then((users)=>{
  for (let i = 0; i < users.length; i++) {
    let object = users[i];
    console.log(object)

  }
  }, (error) => {
    console.log(error);
  });

but it did not work

any help will be appreciated

1
the problem in these two line of codes: var relation = currentUser.relation('blocking') query.doesNotExist(relation); - Marcos T. Gobriel

1 Answers

4
votes

I managed to do it myself

at first i query the relation and store a list of blocked ids in an array

    var currentUser = Parse.User.current();
      var relation = currentUser.relation("blocking");
      relation.query().find().then(blockedusers=>{
        var blockedIds = []
        for (var i = 0; i<blockedusers.length; i++){
          blockedIds.push(blockedusers[i].id)
        } 
      })

after that i moved the whole query inside the relation find and do (not contained in) this array like the following

         query.notContainedIn("objectId", blockedIds)

that solved my problem

thanks