Documentation ¶
Index ¶
- Constants
- func Collection(name string) *mgo.Collection
- func DB() *mgo.Database
- func EmailValidator(fieldValue reflect.Value, fieldType reflect.StructField) error
- func Find(model IModel, criteria ICriteria) error
- func FindById(model IModel, id string) error
- func InitDB(connectString, dbName string) error
- func Insert(model IModel) bool
- func Save(model IModel) bool
- func Update(model IModel, attributes Map) bool
- func UrlValidator(fieldValue reflect.Value, fieldType reflect.StructField) error
- func Validate(model IEmbeddedModel) bool
- type Criteria
- func (self *Criteria) AddCond(field, opt string, value interface{}) ICriteria
- func (self *Criteria) AddSort(field string, sort int) ICriteria
- func (self *Criteria) GetConditions() Map
- func (self *Criteria) GetLimit() int
- func (self *Criteria) GetOffset() int
- func (self *Criteria) GetSelect() []string
- func (self *Criteria) GetSort() map[string]int
- func (self *Criteria) SetConditions(conditions Map) ICriteria
- func (self *Criteria) SetLimit(limit int) ICriteria
- func (self *Criteria) SetOffset(offset int) ICriteria
- func (self *Criteria) SetSelect(selects []string) ICriteria
- func (self *Criteria) SetSort(sort map[string]int) ICriteria
- type EmbeddedModel
- type ErrorHandler
- type Event
- type EventFn
- type ICriteria
- type IEmbeddedModel
- type IErrorHandler
- type IEvent
- type IModel
- type IValidator
- type Map
- type Model
- type Query
- type ValidateFn
Constants ¶
View Source
const CriteriaSortAsc int = 1
View Source
const CriteriaSortDesc int = -1
View Source
const EXP_EMAIL = `^[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,4}$`
View Source
const EXP_URL = `` /* 344-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func Collection ¶
func Collection(name string) *mgo.Collection
func EmailValidator ¶
func EmailValidator(fieldValue reflect.Value, fieldType reflect.StructField) error
func UrlValidator ¶
func UrlValidator(fieldValue reflect.Value, fieldType reflect.StructField) error
func Validate ¶
func Validate(model IEmbeddedModel) bool
Types ¶
type Criteria ¶
type Criteria struct {
// contains filtered or unexported fields
}
func (*Criteria) GetConditions ¶
func (*Criteria) SetConditions ¶
type EmbeddedModel ¶
type EmbeddedModel struct { ErrorHandler `bson:",inline" json:"-"` Event `bson:",inline" json:"-"` }
func (*EmbeddedModel) Validate ¶
func (self *EmbeddedModel) Validate() bool
type ErrorHandler ¶
type ErrorHandler struct {
// contains filtered or unexported fields
}
func (*ErrorHandler) AddError ¶
func (self *ErrorHandler) AddError(err string)
func (*ErrorHandler) ClearErrors ¶
func (self *ErrorHandler) ClearErrors()
func (*ErrorHandler) GetErrors ¶
func (self *ErrorHandler) GetErrors() []error
func (*ErrorHandler) HasErrors ¶
func (self *ErrorHandler) HasErrors() bool
type ICriteria ¶
type ICriteria interface { AddSort(field string, sort int) ICriteria SetSort(sort map[string]int) ICriteria GetSort() map[string]int SetSelect(selects []string) ICriteria GetSelect() []string GetLimit() int SetLimit(limit int) ICriteria GetOffset() int SetOffset(offset int) ICriteria GetConditions() Map SetConditions(conditions Map) ICriteria AddCond(field, opt string, value interface{}) ICriteria }
func NewCriteria ¶
func NewCriteria() ICriteria
type IEmbeddedModel ¶
type IEmbeddedModel interface { IErrorHandler IValidator IEvent }
type IErrorHandler ¶
type IValidator ¶
type IValidator interface {
Validate() bool
}
type Model ¶
type Model struct { EmbeddedModel `bson:",inline" json:"-"` Id bson.ObjectId `bson:"_id" json:"id"` // contains filtered or unexported fields }
func (*Model) BeforeSave ¶
type ValidateFn ¶
type ValidateFn func(fieldValue reflect.Value, fieldType reflect.StructField) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.