如何在Parse Signup函数中添加额外的属性?

时间:2012-11-01 07:37:07

标签: javascript android parsing mobile

我想在解析SignUp函数中添加一个额外的属性。我的代码就像

signUp: function(e) {
  var self = this;
  var username = this.$("#signup-username").val();
  var password = this.$("#signup-password").val();
  var sex=this.$("#signup-sex").val();
  Parse.User.signUp(username, password, sex, { ACL: new Parse.ACL() }, {
    success: function(user) {
      new ManageTodosView();
      self.undelegateEvents();
      delete self;
    }

如果我只传递用户名和密码,它就会起作用并将用户添加到数据库中。

3 个答案:

答案 0 :(得分:2)

var attrs = {ACL: new Parse.ACL(), email: "email@email.com"};

Parse.User.signUp(username, password, attrs, {

    success: function(user) {
      //Set the code for sucess
    },

    error: function(user, error) {
     alert("Error: " + error.code + " " + error.message);
    }
});

答案 1 :(得分:1)

你可以这样做

var user = new Parse.User();
user.set('username',name);
user.set('YOUR_COLUMN','ITS_VALUE');
user.set('password',password);
user.set('YOUR_COULMN','ITS_VALUE');

user.signUp(null,{
    success:function(user){
        NEXT OPERATION
    },
    error:function(error){
        res.send('error::'+error.message);
  }

});

答案 2 :(得分:0)

文档仅显示Parse.User.signUp函数的4个参数:http://www.parse.com/docs/js/symbols/Parse.User.html#signUp

我的猜测是这样可以解决问题:

signUp: function (e) {
    var self = this;
    var username = this.$("#signup-username").val();
    var password = this.$("#signup-password").val();
    var sex = this.$("#signup-sex").val();
    var otherAttribute = 'test';
    Parse.User.signUp(username, password, {
        sex: sex,
        newAttribute: otherAttribute,
        ACL: new Parse.ACL()
    }, {
        success: function (user) {
            new ManageTodosView();
            self.undelegateEvents();
            delete self;
        }
    }
}