Documentation ¶
Index ¶
- Variables
- type Mongo
- func (m *Mongo) CreateAddress(a *users.Address, userid string) error
- func (m *Mongo) CreateCard(ca *users.Card, userid string) error
- func (m *Mongo) CreateUser(u *users.User) error
- func (m *Mongo) Delete(entity, id string) error
- func (m *Mongo) EnsureIndexes() error
- func (m *Mongo) GetAddress(id string) (users.Address, error)
- func (m *Mongo) GetAddresses() ([]users.Address, error)
- func (m *Mongo) GetCard(id string) (users.Card, error)
- func (m *Mongo) GetCards() ([]users.Card, error)
- func (m *Mongo) GetUser(id string) (users.User, error)
- func (m *Mongo) GetUserAttributes(u *users.User) error
- func (m *Mongo) GetUserByName(name string) (users.User, error)
- func (m *Mongo) GetUsers() ([]users.User, error)
- func (m *Mongo) Init() error
- func (m *Mongo) Ping() error
- type MongoAddress
- type MongoCard
- type MongoUser
Constants ¶
This section is empty.
Variables ¶
View Source
var ( //ErrInvalidHexID represents a entity id that is not a valid bson ObjectID ErrInvalidHexID = errors.New("Invalid Id Hex") )
Functions ¶
This section is empty.
Types ¶
type Mongo ¶
type Mongo struct {
//Session is a MongoDB Session
Session *mgo.Session
}
Mongo meets the Database interface requirements
func (*Mongo) CreateAddress ¶
CreateAddress Inserts Address into MongoDB
func (*Mongo) CreateCard ¶
CreateCard adds card to MongoDB
func (*Mongo) CreateUser ¶
CreateUser Insert user to MongoDB, including connected addresses and cards, update passed in user with Ids
func (*Mongo) EnsureIndexes ¶
EnsureIndexes ensures username is unique
func (*Mongo) GetAddress ¶
GetAddress Gets an address by object Id
func (*Mongo) GetAddresses ¶
GetAddresses gets all addresses
func (*Mongo) GetUserAttributes ¶
GetUserAttributes given a user, load all cards and addresses connected to that user
func (*Mongo) GetUserByName ¶
GetUserByName Get user by their name
type MongoAddress ¶
MongoAddress is a wrapper for Address
type MongoUser ¶
type MongoUser struct { users.User `bson:",inline"` ID bson.ObjectId `bson:"_id"` AddressIDs []bson.ObjectId `bson:"addresses"` CardIDs []bson.ObjectId `bson:"cards"` }
MongoUser is a wrapper for the users
func (*MongoUser) AddUserIDs ¶
func (mu *MongoUser) AddUserIDs()
AddUserIDs adds userID as string to user
Click to show internal directories.
Click to hide internal directories.