Reputation: 183
Is it possible to write a cloud code function directly into android studio? If not where could I write one? I can't find it on my parse dashboard
thanks
Upvotes: 1
Views: 1521
Reputation: 51
Cloud code is only written in the express module of your app inside cloud/main.js file, you can create cloud functions there and call them from your android app. Example:
Parse.Cloud.define("getPosts", function(request, response){
var query = new Parse.Query("Posts");
//TODO: query constraints here
query.equalTo("key",request.params.text);
query.find().then(function(results){
response.success(results);
});
});
and you can call this function from android as below:
public static void getPosts(String text, final onSearch onSearch) {
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("text", text);
ParseCloud.callFunctionInBackground("getPosts", hashMap, new
FunctionCallback<List<Post>>() {
@Override
public void done(List<Post> object, ParseException e) {
//TODO: use search results...
}
});
}
you can see other cloud functions and parameters in the docs: Cloud Code Guide
Upvotes: 5