Documentation ¶
Overview ¶
Package usermgo provides a auto-generated package which contains a sql CRUD API for the specific User struct in package api.
Index ¶
- Variables
- type Config
- type MongoDB
- type UserConsumer
- type UserDB
- func (mdb *UserDB) Count(ctx context.Context) (int, error)
- func (mdb *UserDB) Create(ctx context.Context, elem api.User) error
- func (mdb *UserDB) Delete(ctx context.Context, publicID string) error
- func (mdb *UserDB) Exec(ctx context.Context, isread bool, fx func(col *mgo.Collection) error) error
- func (mdb *UserDB) Get(ctx context.Context, publicID string) (api.User, error)
- func (mdb *UserDB) GetAll(ctx context.Context, order string, orderBy string, page int, ...) ([]api.User, int, error)
- func (mdb *UserDB) GetAllByOrder(ctx context.Context, order, orderBy string) ([]api.User, error)
- func (mdb *UserDB) GetByField(ctx context.Context, key string, value interface{}) (api.User, error)
- func (mdb *UserDB) Update(ctx context.Context, publicID string, elem api.User) error
- type UserFields
- type Validation
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("record not found") ErrExpiredContext = errors.New("context has expired") )
errors ...
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { DB string `toml:"db" json:"db"` AuthDB string `toml:"authdb" json:"authdb"` User string `toml:"user" json:"user"` Password string `toml:"password" json:"password"` Host string `toml:"host" json:"host"` }
Config embodies the data used to connect to user's mongo connection.
type MongoDB ¶
MongoDB defines a interface which exposes a method for retrieving a mongo.Database and mongo.Session.
func NewMongoDB ¶
NewMongoDB returns a new instance of a MongoDB.
type UserConsumer ¶
UserConsumer defines an interface which accepts a map of data which will be consumed into the giving implementing structure as decided by the structure.
type UserDB ¶
type UserDB struct {
// contains filtered or unexported fields
}
UserDB defines a structure which provide DB CRUD operations using mongo as the underline db.
func (*UserDB) Create ¶
Create attempts to add the record into the db using the provided instance of the api.User. Records using this DB must have a public id value, expressed either by a bson or json tag on the given User struct.
func (*UserDB) Delete ¶
Delete attempts to remove the record from the db using the provided publicID. Records using this DB must have a public id value, expressed either by a bson or json tag on the given api.User struct.
func (*UserDB) Exec ¶
Exec provides a function which allows the execution of a custom function against the collection.
func (*UserDB) Get ¶
Get retrieves a record from the db using the publicID and returns the api.User type. Records using this DB must have a public id value, expressed either by a bson or json tag on the given User struct.
func (*UserDB) GetAll ¶
func (mdb *UserDB) GetAll(ctx context.Context, order string, orderBy string, page int, responsePerPage int) ([]api.User, int, error)
GetAll retrieves all records from the db and returns a slice of api.User type. Records using this DB must have a public id value, expressed either by a bson or json tag on the given User struct.
func (*UserDB) GetAllByOrder ¶
GetAllByOrder retrieves all records from the db and returns a slice of api.User type. Records using this DB must have a public id value, expressed either by a bson or json tag on the given User struct.
func (*UserDB) GetByField ¶
GetByField retrieves a record from the db using the provided field key and value returns the api.User type. Records using this DB must have a public id value, expressed either by a bson or json tag on the given User struct.
type UserFields ¶
UserFields defines an interface which exposes method to return a map of all attributes associated with the defined structure as decided by the structure.
type Validation ¶
type Validation interface {
Validate() error
}
Validation defines an interface which expose a method to validate a giving type.