title: PFQuery.find on objectId is not returning a unique row in Parse JavaScript SDK (Cloud Code)
body: <p>I am new to Parse and Cloud Code, but I have managed to write a few AfterSave Cloud Code functions that work fine.  However, I am having a lot of trouble with this one, and I cannot figure out why.  Please help...</p>
  
  <p>I have</p>
  
  <ul>
  <li>Two PFObject classes: Message and MessageThread</li>
  <li>Message contains chat messages that are associated with a MessageThread</li>
  <li>MessageThread contains an array of members (which are all PFUsers)</li>
  <li><p>Upon insert to Message, I want to look up all the members of the related MessageThread and Push notifications to them</p>
  
  <pre><code>class MessageThread: PFObject {
  
      @NSManaged var members: [PFUser]
      @NSManaged var lastMessageDate: NSDate?
      @NSManaged var messageCount: NSNumber?
  
      override class func query() -&gt; PFQuery? {
          let query = PFQuery(className: MessageThread.parseClassName())
          query.includeKey("members")
          return query
      }
      init(members: [PFUser], lastMessageDate: NSDate?, messageCount: NSNumber?) {
          super.init()
  
          self.members = members
          self.lastMessageDate = lastMessageDate
          self.messageCount = messageCount
      }
  
      override init() {
          super.init()
      }
  }
  extension MessageThread: PFSubclassing {
      class func parseClassName() -&gt; String {
          return "MessageThread"
      }
      override class func initialize() {
          var onceToken: dispatch_once_t = 0
          dispatch_once(&amp;onceToken) {
              self.registerSubclass()
          }
      }
  }
  class Message: PFObject {
      @NSManaged var messageThreadParent: MessageThread
      @NSManaged var from: PFUser
      @NSManaged var message: String
      @NSManaged var image: PFFile?
  
      override class func query() -&gt; PFQuery? {
          let query = PFQuery(className: Message.parseClassName())
          query.includeKey("messageThreadParent")
          return query
      }
      init( messageThreadParent: MessageThread, from: PFUser, message: String, image: PFFile?) {
          super.init()
  
          self.messageThreadParent = messageThreadParent
          self.from = from
          self.message = message
          self.image = image
          }
      override init() {
          super.init()
      }
  }
  extension Message: PFSubclassing {
      class func parseClassName() -&gt; String {
          return "Message"
      }
      override class func initialize() {
          var onceToken: dispatch_once_t = 0
          dispatch_once(&amp;onceToken) {
              self.registerSubclass()
          }
      }
  }
  </code></pre></li>
  </ul>
  
  <p>Approach</p>
  
  <ul>
  <li>From the request object (a Message), get its messageThreadParent</li>
  <li>Lookup the members of the parent MessageThread, loop through them, etc.</li>
  </ul>
  
  <p>The problem</p>
  
  <ul>
  <li><p>When I try to retrieve the MessageThread object, I attempt to query on Id == threadParent.objectId.  However, this query always returns all 8 of my current MessageThreads, rather than the single one I need.</p>
  
  <pre><code>Parse.Cloud.afterSave(Parse.Object.extend("Message"), function(request) {
  
  Parse.Cloud.useMasterKey();
  
  var theMsg = request.object;
  var threadParent;
  var currUsername = request.user.get("username");
  var threadUsers;
  var usernameArray;
  
  threadParent = request.object.get("messageThreadParent");
  
  // promise 
  queryM = new Parse.Query(Parse.Object.extend("MessageThread"));
  queryM.include("members");
  queryM.equalTo("id", threadParent.objectId);
  queryM.find().then(function (threadParam) {
  
  console.log(" threads: ");
  console.log(threadParam.length); //this returns 8, which is the number of threads I have.  I would expect just 1, matching threadParent.objectId...
  console.log("thread is: ");
  
  //... additional code follows, which seems to work...
  </code></pre></li>
  </ul>