Documentation
¶
Index ¶
Constants ¶
View Source
const ( DBName = "docker" CName = "users" )
DBName is name of the database and CName is the name of document collection
Variables ¶
This section is empty.
Functions ¶
func CreateInitDocument ¶
func CreateInitDocument(m *mgo.Collection)
CreateInitDocument initializes collection with 50 users
func GetSession ¶
GetSession will create a session if doesn't exist else will return existing session
func Query ¶
func Query(m *mgo.Collection, query interface{}) interface{}
Query conducts search on mongodb collection
Types ¶
type Context ¶
Context is an mgo session
func (*Context) DBCollection ¶
func (c *Context) DBCollection() *mgo.Collection
DBCollection returns mgo collection
type Model ¶
Model is a mgo struct data type
type Store ¶
type Store interface { Create(m *Model) Model GetAll() ([]Model, error) GetByID(m *Model) (Model, error) Update(m *Model) (Model, error) Delete(m *Model) (Model, error) }
Store has CRUD methods for mongodb
type UserModel ¶
type UserModel struct { ID int `json:"id"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Email string `json:"email"` Gender string `json:"gender"` }
UserModel Struct is the model for the app
Click to show internal directories.
Click to hide internal directories.