Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Parse.Cloud.define("hello", function(request, response) {
- Parse.User.logIn("mac@a.com", "111111", {
- success: function(user) {
- // results has the list of users with a hometown team with a winning record
- console.log("user id is:"+user.id)
- var Hive = Parse.Object.extend("Hive");
- var hive = new Hive();
- hive.set("message", "first global message");
- hive.set("tags", "#cloudcode");
- hive.set('user', user);
- hive.save(null, {
- success: function(hive) {
- // Execute any logic that should take place after the object is saved.
- alert('New object created with objectId: ' + hive.id);
- var query = new Parse.Query(Parse.Installation);
- Parse.Push.send({
- where: query, // Set our Installation query
- data: {
- alert: hive.get('message')
- }
- }, {
- success: function() {
- // Push was successful
- },
- error: function(error) {
- // Handle error
- }
- });
- },
- error: function(hive, error) {
- // Execute any logic that should take place if the save fails.
- // error is a Parse.Error with an error code and message.
- alert('Failed to create new object, with error code: ' + error.message);
- }
- });
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement