ember-parse-adapter
ember-parse-adapter copied to clipboard
CloudCode Functions?
Is there a way to get cloudcode functions working? I want to be able to query a certain model with a POST
request, passing in geolocation data.
POST http://api.parse.com/1/functions/proximity
with
{
lat: 51.0453738,
lon: -114.0566039,
limit: 20, radius: 10,
parseClass: "Event",
distance: 2
}
Is this possible yet? If not, how can it be implemented?
I accomplished this by editing the pathForType function in addon/adapters/application.js. Add a case for "functions". Then I use this code to make a function call:
Adapter.ajax(Adapter.buildURL("function", "someCloudFunction"), "POST", {
data: {
foo: bar
}
});
@joshfester nice one!
@joshfoster, would you have to use a model of type function
in that case? What would ember data integration look like?
In my app it ended up being easiest to just put the functions on the application route since I only use a handful of cloud functions.
To me it would make the most sense if every model could have "functions" the same way that controllers have "actions". Then you could call someModel.cloudFunction(data)
@joshfester, can you provide an example? In my case, I'm simply looking to query a set of data based on the user's current location, so I don't quite follow how I would set a route's model to the result.
Perhaps you could add an example to the dummy app?
@srsgores sorry I should have clarified. My suggestion was a feature request to solve this issue via the adapter. In your case I'd suggest using my quick fix until support gets added to the adapter.