Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Added Function class to handle calling CloudCode functions. Also adde…
…d test cases for hello and averageStars functions, which necessitated adding a cloudcode directory to upload those functions to the test application, as well as requiring MASTER_KEY in the settings_local.py file. Added CloudCode documentation to README.mkd.
- Loading branch information
David Robinson
committed
Jan 19, 2013
1 parent
895cb68
commit b640110
Showing
7 changed files
with
165 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ | |
build/* | ||
settings_local.py | ||
dist | ||
MANIFEST | ||
MANIFEST | ||
global.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
// Use Parse.Cloud.define to define as many cloud functions as you want. | ||
// For example: | ||
Parse.Cloud.define("hello", function(request, response) { | ||
response.success("Hello world!"); | ||
}); | ||
|
||
|
||
Parse.Cloud.define("averageStars", function(request, response) { | ||
var query = new Parse.Query("Review"); | ||
query.equalTo("movie", request.params.movie); | ||
query.find({ | ||
success: function(results) { | ||
var sum = 0; | ||
for (var i = 0; i < results.length; ++i) { | ||
sum += results[i].get("stars"); | ||
} | ||
response.success(sum / results.length); | ||
}, | ||
error: function() { | ||
response.error("movie lookup failed"); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters