models

package
v0.0.0-...-86f6099 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2014 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Collections map[string]string
)

Functions

func Collection

func Collection(m interface{}, s *mgo.Session) *mgo.Collection

Types

type Article

type Article struct {
	Model     `bson:",inline"`
	Author_id bson.ObjectId          `bson:"Author_id"`
	Published bool                   `bson:"Published"`
	Posted    time.Time              `bson:"Posted"`
	Title     string                 `bson:"Title"`
	Body      string                 `bson:"Body"`
	Tags      []string               `bson:"Tags"`
	Alias     string                 `bson:"Alias"`
	Meta      map[string]interface{} `bson:",omitempty"`
}

func GetArticleById

func GetArticleById(s *mgo.Session, Id string) *Article

func GetArticleByObjectId

func GetArticleByObjectId(s *mgo.Session, Id bson.ObjectId) *Article

func GetArticlesByDate

func GetArticlesByDate(s *mgo.Session, limit int) []*Article

func GetArticlesByTag

func GetArticlesByTag(s *mgo.Session, t string) []*Article

func GetArticlesByTitle

func GetArticlesByTitle(s *mgo.Session, Title string) []Article

func (*Article) AddMeta

func (article *Article) AddMeta(s *mgo.Session)

func (*Article) CanBeCreatedBy

func (article *Article) CanBeCreatedBy(s *mgo.Session, u *User) bool

func (*Article) CanBeDeletedBy

func (article *Article) CanBeDeletedBy(s *mgo.Session, u *User) bool

func (*Article) CanBeUpdatedBy

func (article *Article) CanBeUpdatedBy(s *mgo.Session, u *User) bool

func (*Article) Delete

func (article *Article) Delete(s *mgo.Session) error

func (*Article) GetAuthor

func (article *Article) GetAuthor(s *mgo.Session) *User

func (*Article) Save

func (article *Article) Save(s *mgo.Session) error

func (*Article) Validate

func (article *Article) Validate(v *revel.Validation)

type Model

type Model struct {
	Id bson.ObjectId `bson:"_id,omitempty"`
}

Empty struct to embed in models that will provide application default funcs.

func (*Model) CanBeCreatedBy

func (m *Model) CanBeCreatedBy(s *mgo.Session, u *User) bool

It is expected that each model will embed the type 'Model' and then extend or override the following functions to enforce corresponding business rules.

func (*Model) CanBeDeletedBy

func (m *Model) CanBeDeletedBy(s *mgo.Session, u *User) bool

func (*Model) CanBeReadBy

func (m *Model) CanBeReadBy(s *mgo.Session, u *User) bool

func (*Model) CanBeUpdatedBy

func (m *Model) CanBeUpdatedBy(s *mgo.Session, u *User) bool

type Password

type Password struct {
	Pass        string
	PassConfirm string
}

type User

type User struct {
	Model          `bson:",inline"`
	Firstname      string              `bson:"Firstname"`
	Lastname       string              `bson:"Lastname"`
	Email          string              `bson:"Email"`
	HashedPassword []byte              `bson:"HashedPassword"`
	Meta           map[string][]string `bson:",omitempty"`
}

func GetUserByEmail

func GetUserByEmail(s *mgo.Session, Email string) *User

func GetUserByObjectId

func GetUserByObjectId(s *mgo.Session, Id bson.ObjectId) *User

func (*User) CanBeCreatedBy

func (user *User) CanBeCreatedBy(s *mgo.Session, u *User) bool

func (*User) CanBeDeletedBy

func (user *User) CanBeDeletedBy(s *mgo.Session, u *User) bool

func (*User) CanBeReadBy

func (user *User) CanBeReadBy(s *mgo.Session, u *User) bool

func (*User) CanBeUpdatedBy

func (user *User) CanBeUpdatedBy(s *mgo.Session, u *User) bool

func (*User) Delete

func (user *User) Delete(s *mgo.Session) error

func (*User) Save

func (user *User) Save(s *mgo.Session, p Password) error

Save a user to the database. If a struct with p.Pass != nil is passed this will update the user's password as well. This returns the error value from mgo.Upsert()

func (*User) String

func (user *User) String() string

func (*User) Validate

func (user *User) Validate(v *revel.Validation)

func (*User) ValidatePassword

func (user *User) ValidatePassword(v *revel.Validation, password Password)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL