// UserCreate creates user func UserCreate(first_name, last_name, email, password string) error { var err error now := time.Now() switch database.ReadConfig().Type { case database.TypeMySQL: _, err = database.Sql.Exec("INSERT INTO user (first_name, last_name, email, password) VALUES (?,?,?,?)", first_name, last_name, email, password) case database.TypeMongoDB: if database.CheckConnection() { session := database.Mongo.Copy() defer session.Close() c := session.DB(database.ReadConfig().MongoDB.Database).C("user") user := &User{ ObjectId: bson.NewObjectId(), First_name: first_name, Last_name: last_name, Email: email, Password: password, Status_id: 1, Created_at: now, Updated_at: now, Deleted: 0, } err = c.Insert(user) } else { err = ErrUnavailable } case database.TypeBolt: user := &User{ ObjectId: bson.NewObjectId(), First_name: first_name, Last_name: last_name, Email: email, Password: password, Status_id: 1, Created_at: now, Updated_at: now, Deleted: 0, } err = database.Update("user", user.Email, &user) default: err = ErrCode } return standardizeError(err) }
// UserCreate creates user func UserCreate(first_name, last_name, email, password string) error { var err error now := time.Now() user := &User{ ObjectId: bson.NewObjectId(), First_name: first_name, Last_name: last_name, Email: email, Password: password, Status_id: 1, Created_at: now, Updated_at: now, Deleted: 0, } err = database.Update("user", user.Email, &user) return standardizeError(err) }