javascript - How to get a record with an objectId for the Pointer field? -


let's have objectid of record category class , need fetch subcategories (from subcategory class) belong category. subcategory.categoryid pointer field category. if this:

// state  .state('app.create-chambba', {   cache: false,   url: "/services/create-chambba/:categoryid",   views: {     "menucontent": {       templateurl: "views/app/services/create_chambba.html",       controller: "createchambbactrl"     }   } })  // controller  var subcategory = parse.object.extend("subcategory"); var query = new parse.query(subcategory); query.equalto("isactive", true); query.equalto("categoryid", $stateparams.categoryid); // categoryid "aophm46mtr"  query.ascending("name"); query.find(...); 

i get:

message: "pointer field categoryid needs pointer value" 

so ended doing:

var category = parse.object.extend("category"); var querycategory = new parse.query(category); querycategory.equalto("objectid", $stateparams.categoryid); querycategory.first({     success: function(category) {         var subcategory = parse.object.extend("subcategory");         var query = new parse.query(subcategory);         query.equalto("isactive", true);         query.equalto("categoryid", category);         query.ascending("name");         query.find(..);     } }); 

isn't work? there better way?

create new object of category , put id of object id search.

  var category = new category();     category.id=$stateparams.categoryid;     .... 

and use category object pointer .

  query.equalto("categoryid", catagory);  

this little hack should solve problem.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -