ember-parse-adapter icon indicating copy to clipboard operation
ember-parse-adapter copied to clipboard

CloudCode Functions?

Open srsgores opened this issue 9 years ago • 6 comments

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?

srsgores avatar Apr 26 '15 19:04 srsgores

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 avatar Apr 26 '15 21:04 joshfester

@joshfester nice one!

quantuminformation avatar Apr 26 '15 21:04 quantuminformation

@joshfoster, would you have to use a model of type function in that case? What would ember data integration look like?

srsgores avatar Apr 26 '15 22:04 srsgores

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 avatar Apr 26 '15 22:04 joshfester

@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 avatar Apr 26 '15 22:04 srsgores

@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.

joshfester avatar Apr 26 '15 22:04 joshfester