Use string instead of ID type

This commit is contained in:
2016-12-20 16:52:26 +01:00
parent 83c36f00bf
commit 7c197ff49d
5 changed files with 7 additions and 8 deletions

2
id.go
View File

@ -5,5 +5,5 @@ type ID [16]byte
// IDGenerator generates new IDs
type IDGenerator interface {
New() ID
New() string
}

View File

@ -1,5 +1,5 @@
CREATE TABLE users (
id uuid,
id char(26),
email text,
name text,
password text

View File

@ -12,7 +12,7 @@ type UserService struct {
}
// User returns a user for a given id.
func (s *UserService) User(id budgeteer.ID) (*budgeteer.User, error) {
func (s *UserService) User(id string) (*budgeteer.User, error) {
u := &budgeteer.User{ID: id}
err := s.DB.Select(&u)
if err != nil {

View File

@ -4,7 +4,6 @@ import (
"math/rand"
"time"
"git.javil.eu/jacob1123/budgeteer"
"github.com/oklog/ulid"
)
@ -22,7 +21,7 @@ func NewGenerator() (*UlidGenerator, error) {
return ug, nil
}
func (ug *UlidGenerator) New() budgeteer.ID {
func (ug *UlidGenerator) New() string {
id := ulid.MustNew(ulid.Timestamp(time.Now()), ug.entropy)
return budgeteer.ID(id)
return id.String()
}

View File

@ -2,7 +2,7 @@ package budgeteer
// User struct contains Login information
type User struct {
ID ID
ID string
Email string
Password string
Name string
@ -10,7 +10,7 @@ type User struct {
// UserService provides Methods for CRUD of Users
type UserService interface {
User(id ID) (*User, error)
User(id string) (*User, error)
UserByUsername(username string) (*User, error)
//Users() ([]*User, error)
CreateUser(u *User) error