Small progress on adding collaborator
This commit is contained in:
@@ -31,7 +31,7 @@ func (self *rethinkStore) SaveUserAccount(account *models.UserAccount) error {
|
||||
return err
|
||||
}
|
||||
|
||||
account.DatabaseId = accountId
|
||||
account.Id = accountId
|
||||
|
||||
resp, err := r.Table("accounts").Insert(account).RunWrite(self.session)
|
||||
if err != nil {
|
||||
@@ -61,6 +61,22 @@ func (self *rethinkStore) GetUserAccountLogin(emailOrName string) (*models.UserA
|
||||
return &account, nil
|
||||
}
|
||||
|
||||
func (self *rethinkStore) GetAccount(id int) (*models.UserAccount, error) {
|
||||
resp, err := r.Table("accounts").Get(id).Run(self.session)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var account models.UserAccount
|
||||
err = resp.One(&account)
|
||||
if err != nil {
|
||||
return nil, errors.New("Not found")
|
||||
}
|
||||
|
||||
return &account, nil
|
||||
}
|
||||
|
||||
func (self *rethinkStore) getNextDashboardNumber(accountId int) (int, error) {
|
||||
resp, err := r.Table("accounts").Get(accountId).Update(map[string]interface{}{
|
||||
"NextDashboardId": r.Row.Field("NextDashboardId").Add(1),
|
||||
|
||||
@@ -38,17 +38,17 @@ func TestRethinkStore(t *testing.T) {
|
||||
account := &models.UserAccount{UserName: "torkelo", Email: "mupp", Login: "test@test.com"}
|
||||
err := store.SaveUserAccount(account)
|
||||
So(err, ShouldBeNil)
|
||||
So(account.DatabaseId, ShouldNotEqual, 0)
|
||||
So(account.Id, ShouldNotEqual, 0)
|
||||
|
||||
read, err := store.GetUserAccountLogin("test@test.com")
|
||||
So(err, ShouldBeNil)
|
||||
So(read.DatabaseId, ShouldEqual, account.DatabaseId)
|
||||
So(read.Id, ShouldEqual, account.DatabaseId)
|
||||
})
|
||||
|
||||
Convey("can get next dashboard id", t, func() {
|
||||
account := &models.UserAccount{UserName: "torkelo", Email: "mupp"}
|
||||
err := store.SaveUserAccount(account)
|
||||
dashId, err := store.getNextDashboardNumber(account.DatabaseId)
|
||||
dashId, err := store.getNextDashboardNumber(account.Id)
|
||||
So(err, ShouldBeNil)
|
||||
So(dashId, ShouldEqual, 1)
|
||||
})
|
||||
|
||||
@@ -11,6 +11,7 @@ type Store interface {
|
||||
Query(query string, acccountId int) ([]*models.SearchResult, error)
|
||||
SaveUserAccount(acccount *models.UserAccount) error
|
||||
GetUserAccountLogin(emailOrName string) (*models.UserAccount, error)
|
||||
GetAccount(id int) (*models.UserAccount, error)
|
||||
Close()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user