I have created in parse several classes and many of them related to each other by Pointers. An example is the following.
I have 2 classes:
-
subcategorias
-
comercios
In comercios
I can have records of many trades, there is a field called come_subc_id
and it is linked to class subcategorias
by means of a Pointer.
In class subcategorias
I have a classification of all shops, ie if it is a hotel, a restaurant, laundry, etc.
I have a PFQueryTableViewController
where I intend to show a list of, for example, all hotels.
If in my class subcategorias
for example the objectId
of hotels is gL8qGBhXMI
, how can I generate the query to show me only in the table all the hotels that I have registered in the business class? My question is, how can I generate a query of a class accessing the fields of another class through the pointer? I am trying it in the following way, but with errors and I have the following code and I still can not refine it and I do not know if I am going in the right direction.
override func queryForTable() -> PFQuery {
let queryHot = PFQuery(className: "comercios") //El que funciona
queryHot.includeKey("come_subc_id") //Tipo pointer apuntando a clase subcategorias
queryHot.whereKey("come_subc_id", equalTo: "gL8qGBhXMI") // comparando si el registro tiene clasificacion de hotel
return queryHot
}
When running the application I get the following error:
2016-01-24 14:05:35.579 AppBeta1[1045:35017] [Error]: pointer field come_subc_id needs a pointer value (Code: 102, Version: 1.11.0)
I understand that the error is generated in the query when I make the comparison:
queryHot.whereKey("come_subc_id", equalTo: "gL8qGBhXMI")
Since the field come_subc_id
is not type string
but it is an object, my question is about how to implement the correct method to make this comparison, if I can understand this part I can practically perform all the queries that are generated in my application since all classes are related by Pointers.
If I have not been entirely clear, I can rethink my problem.
I appreciate your support.