How to query value of column that is set as pointer to other table in Parse

后端 未结 3 1186
日久生厌
日久生厌 2021-02-06 01:52

I am using Parse for my app. I want to query a table with column that set to be a pointer to other table. Here is the query:

ParseQuery query = new ParseQuery(\"         


        
相关标签:
3条回答
  • 2021-02-06 02:24

    @Akshat Agarwal, here is a example in JavaScript:

    var parseObj = Parse.Object.extend('parseObj');
    
    new Parse.Query(parseObj)
      .include('pointerField')
      .find(function (data) {
        data.get('pointerField').get('fieldName');
      });
    
    0 讨论(0)
  • 2021-02-06 02:30

    Here is the solution to this one:

    First you need to create a ParseObject from the type of your table:

    ParseObject sale = ParseObject.createParseObject("Sale"); 
    

    Then you need to get the ParseObject from the result:

    sale = result.getParseObject(pointer_field);
    

    Now you can pull from sale any field that it has just as you would do it normally, for example:

    sale.getString("some_field")
    

    Note: When you are doing your query you must to include the pointer field if you want to be able to extract the data from it after the query will be returned. The result:

    query.include("pointer_field")
    

    Hope it helps

    0 讨论(0)
  • 2021-02-06 02:46

    For iOS

      PFQuery *parseQuery = [PFQuery queryWithClassName:@"MyClass"];
      [parseQuery whereKey:@"categoryId" equalTo:categoryId];
      [parseQuery includeKey:@"pinter_field"];
      [parseQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
      //
      }];
    
    0 讨论(0)
提交回复
热议问题