Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetCollectionName ¶
SetCollectionName changes the name of the mongodb collection.
Types ¶
type Database ¶
type Database interface { Connect() error Disconnect() error FindUserByMail(string) (*User, error) FindUserByID(string) (*User, error) }
Database describe all database interaction.
func NewMongoConnection ¶
NewMongoConnection creates a new mongo database connection. It takes functional parameters to change default options such as the mongo url It returns the newly created server or an error if something went wrong.
type MGO ¶
type MGO struct {
// contains filtered or unexported fields
}
MGO implements the database interface, representing a mongodb connection.
func (MGO) Disconnect ¶
Disconnect closes the connection to the mongodb server.
func (MGO) FindUserByID ¶
FindUserByID searches for a user with the given id.
type User ¶
type User struct { ID primitive.ObjectID `bson:"_id,omitempty"` Mail string `bson:"mail"` Password string `bson:"password"` Roles []string `bson:"roles"` }
User represents a user document.
func (*User) ValidatePassword ¶
ValidatePassword validates the given plaintext password for the user
Click to show internal directories.
Click to hide internal directories.