Search code examples
parse-platformember-model

Parse.com manipulate Response Object


I am trying to work Ember with Parse.com using ember-model-parse-adapter by samharnack.

I add added a function to make multiple work search(like search engine) for which I have defined a function on cloud using Parse.Cloud.define and run from client. The problem is the Array that my cloud response returns is not compatible with Ember Model because of two attributes they are __type and className. how can I modify the response to get response similar to that i get when I run a find query from client. i.e without __type and className

Example responses for App.List.find() = { "results":[ { "text":"zzz", "words":[ "zzz" ], "createdAt":"2013-06-25T16:19:04.120Z", "updatedAt":"2013-06-25T16:19:04.120Z", "objectId":"L1X55krC8x" } ] }

for App.List.cloudFunction("sliptSearch",{"text" : this.get("searchText")})

{
   "results":[
      {
         "text":"zzz",
         "words":[
            "zzz"
         ],
         "createdAt":"2013-06-25T16:19:04.120Z",
         "updatedAt":"2013-06-25T16:19:04.120Z",
         "objectId":"L1X55krC8x",
         "__type" : Object,             //undesired
         "className" : "Lists"          //undesired

      }
   ]
}

Solution

  • Thanks Vlad something like this worked for me for array

    resultobj = []; 
    
    searchListQuery.find({
         success: function(results) {
             for( var i=0, l=results.length; i<l; i++ ) {
                 temp = results.pop();
                        resultobj.push({
                             text: temp.get("text"),
                             createdAt: temp.createdAt,
                             updatedAt: temp.updatedAt,
                             objectId: temp.id,
                             words: "",
                             hashtags: ""
                        });
                    }