1

hey guys i have a table A which has a pointer to Table B. I am trying to query Table A where Table B created At is less than today

Table A (columns)

objectId, Name, Table B pointer, ....

Table B

objectId, EndDate

So far I have this

    let query = PFQuery(className:Globals.ParseObjects.ProLeagueWinnings)
    query.fromLocalDatastore()
    query.fromPinWithName("XXX")

    query.includeKey("TableB")

    query.whereKeyExists("TableB")
    query.whereKey("TableB.EndDate", lessThanOrEqualTo: NSDate())
    query.findObjectsInBackground().continueWithSuccessBlock {
        (task: BFTask!) -> AnyObject! in

        let leagues = task.result as? [ProLeagueWinnings]
        if (completion != nil){
            if leagues != nil{
                completion!(leagues!)
            }else{
                completion!([])
            }
        }

        return task
    }

But it returns everything.

Asif Alamgir
  • 1,454
  • 1
  • 16
  • 41

1 Answers1

0

Instead of using EndDate, you could always use the createdAt attribute that is automatically created for you by Parse.

It is also important to remember that NSDate() will return the current absolute time including the hours, minutes and so on. So you will be getting all objects in the relationship (being pointed to) that were created before the exact instant of execution.

See: How to get current date at midnight

Russell
  • 3,099
  • 2
  • 14
  • 18