Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. Parse.Cloud.define("hello", function(request, response) {
  2.  
  3.  
  4. Parse.User.logIn("mac@a.com", "111111", {
  5. success: function(user) {
  6. // results has the list of users with a hometown team with a winning record
  7. console.log("user id is:"+user.id)
  8. var Hive = Parse.Object.extend("Hive");
  9. var hive = new Hive();
  10. hive.set("message", "first global message");
  11. hive.set("tags", "#cloudcode");
  12. hive.set('user', user);
  13.  
  14. hive.save(null, {
  15. success: function(hive) {
  16. // Execute any logic that should take place after the object is saved.
  17. alert('New object created with objectId: ' + hive.id);
  18.  
  19. var query = new Parse.Query(Parse.Installation);
  20.  
  21. Parse.Push.send({
  22. where: query, // Set our Installation query
  23. data: {
  24. alert: hive.get('message')
  25. }
  26. }, {
  27. success: function() {
  28. // Push was successful
  29. },
  30. error: function(error) {
  31. // Handle error
  32. }
  33. });
  34. },
  35. error: function(hive, error) {
  36. // Execute any logic that should take place if the save fails.
  37. // error is a Parse.Error with an error code and message.
  38. alert('Failed to create new object, with error code: ' + error.message);
  39. }
  40. });
  41.  
  42. }
  43. });
  44. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement