models

package
v0.0.0-...-d8ae0c1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2015 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Album = NewAlbumModel("albums")
View Source
var Notification = NewNotificationModel("notifications")
View Source
var Picture = NewPictureModel("fs", "fs.files")
View Source
var User = NewUserModel("users")

Functions

func ParseBool

func ParseBool(input string) bool

func ParseDate

func ParseDate(input string) time.Time

func ParseFloat64

func ParseFloat64(input string) float64

Types

type AlbumData

type AlbumData struct {
	Id          bson.ObjectId `bson:"_id" json:"id"`
	Name        string        `bson:"name" json:"name"`
	Tags        *tagit.Tags   `bson:"tags" json:"tags"`
	Location    Location      `bson:"location" json:"location"`
	DateRange   DateRange     `bson:"date_range" json:"date_range"`
	Public      bool          `bson:"public" json:"public"`
	NumPictures int           `bson:"num_pictures" json:"num_pictures"`
	User        bson.ObjectId `bson:"user" json:"user"`
	Statistics  []Count       `bson:"_" json:"statistics"`
}

func NewAlbumData

func NewAlbumData() *AlbumData

type AlbumModel

type AlbumModel struct {
	MgoModel
}

func NewAlbumModel

func NewAlbumModel(collection string) *AlbumModel

func (*AlbumModel) Create

func (model *AlbumModel) Create(params system.Params) (album *AlbumData, err error)

func (*AlbumModel) Edit

func (model *AlbumModel) Edit(params system.Params) (*AlbumData, error)

func (*AlbumModel) Find

func (model *AlbumModel) Find(objectId string) (album *AlbumData, err error)

func (*AlbumModel) FindByUser

func (model *AlbumModel) FindByUser(params system.Params) (albums []*AlbumData, err error)

func (*AlbumModel) FindByUserAndFilters

func (model *AlbumModel) FindByUserAndFilters(params system.Params) (*AlbumData, error)

func (*AlbumModel) FindForPicture

func (model *AlbumModel) FindForPicture(picture *PictureMeta) *AlbumData

func (*AlbumModel) IncreaseNumPictures

func (model *AlbumModel) IncreaseNumPictures(objectId interface{}, delta int)

func (*AlbumModel) PopulateWithPictures

func (model *AlbumModel) PopulateWithPictures(album *AlbumData)

func (*AlbumModel) Public

func (model *AlbumModel) Public() (albums []*AlbumData, err error)

func (*AlbumModel) Remove

func (model *AlbumModel) Remove(objectId string) (err error)

type Count

type Count struct {
	Id    string `bson:"_id" json:"id"`
	Count int    `bson:"count" json:"count"`
}

type DateRange

type DateRange struct {
	Start time.Time `bson:"start" json:"start"`
	End   time.Time `bson:"end" json:"end"`
}

func (DateRange) String

func (dr DateRange) String() string

type Location

type Location struct {
	Longitude float64 `bson:"lng" json:"lng"`
	Latitude  float64 `bson:"lat" json:"lat"`
	Name      string  `bson:"name" json:"name"`
}

func (Location) GetBSON

func (l Location) GetBSON() (interface{}, error)

GetBSON is actually implementing the bson.Getter interface so this can be Marshaled into bson.

func (*Location) SetBSON

func (l *Location) SetBSON(raw bson.Raw) error

SetBSON is implementing the bson.Setter interface so this can be Unmarshaled from bson. To implement the Setter interface we need to import the bson package, so we can have the bson.Raw type available. This one may panic with index out of range. We couldn't care less for that at the moment.

func (Location) String

func (l Location) String() string

type MgoModel

type MgoModel struct {
	C    *mgo.Collection
	Grid *mgo.GridFS
	// contains filtered or unexported fields
}

func (*MgoModel) Close

func (model *MgoModel) Close()

func (*MgoModel) Connect

func (model *MgoModel) Connect() (err error)

func (*MgoModel) MgoFind

func (model *MgoModel) MgoFind(objectId string, reciever interface{}) (err error)

func (*MgoModel) SetCollectionName

func (model *MgoModel) SetCollectionName(collection string)

func (*MgoModel) SetGridFSPrefix

func (model *MgoModel) SetGridFSPrefix(prefix string)

type NotificationData

type NotificationData struct {
	Id   bson.ObjectId `bson:"_id" json:"id"`
	Text string        `bson:"text" json:"text"`
	User bson.ObjectId `bson:"user" json:"user"`
}

func NewNotificationData

func NewNotificationData() *NotificationData

type NotificationModel

type NotificationModel struct {
	MgoModel
}

func NewNotificationModel

func NewNotificationModel(collection string) *NotificationModel

func (*NotificationModel) Create

func (model *NotificationModel) Create(params system.Params) (notification *NotificationData, err error)

func (*NotificationModel) Delete

func (model *NotificationModel) Delete(objectId string) error

func (*NotificationModel) Find

func (model *NotificationModel) Find(objectId string) (notification *NotificationData, err error)

func (*NotificationModel) Pop

func (model *NotificationModel) Pop(params system.Params) (notification *NotificationData, err error)

func (*NotificationModel) Send

func (model *NotificationModel) Send(userId bson.ObjectId, text string)

type PictureFile

type PictureFile struct {
	Id          bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"`
	UploadDate  time.Time     `bson:"uploadDate" json:"upload_date"`
	Filename    string        `bson:"filename" json:"filename"`
	ContentType string        `bson:"contentType" json:"content_type"`
	Metadata    PictureMeta   `bson:"metadata" json:"metadata"`
}

type PictureMeta

type PictureMeta struct {
	Id       bson.ObjectId   `bson:"_id,omitempty" json:"id,omitempty"`
	Name     string          `bson:"name" json:"name"`
	Tags     *tagit.Tags     `bson:"tags" json:"tags"`
	Location Location        `bson:"location" json:"location"`
	Date     time.Time       `bson:"date" json:"date"`
	Album    bson.ObjectId   `bson:"album,omitempty" json:"album,omitempty"`
	User     bson.ObjectId   `bson:"user" json:"user"`
	Likes    []bson.ObjectId `bson:"likes" json:"likes"`
}

func NewPictureMeta

func NewPictureMeta() *PictureMeta

func (PictureMeta) CanBeEditedBy

func (pm PictureMeta) CanBeEditedBy(user *UserData) error

func (PictureMeta) CanBeViewedBy

func (pm PictureMeta) CanBeViewedBy(user *UserData) error

type PictureModel

type PictureModel struct {
	MgoModel
}

func NewPictureModel

func NewPictureModel(prefix, collection string) *PictureModel

func (*PictureModel) Create

func (model *PictureModel) Create(params system.Params, formFile multipart.File) (picture *PictureMeta, err error)

func (*PictureModel) Edit

func (model *PictureModel) Edit(params system.Params) (*PictureMeta, error)

func (*PictureModel) Find

func (model *PictureModel) Find(objectId string) (picture *PictureMeta, err error)

func (*PictureModel) FindByAlbum

func (model *PictureModel) FindByAlbum(albumId string) (pictures []*PictureMeta, err error)

func (*PictureModel) FindByUser

func (model *PictureModel) FindByUser(objectId string) (pictures []*PictureMeta, err error)

func (*PictureModel) GetFile

func (model *PictureModel) GetFile(objectId string) (picture *mgo.GridFile, err error)

func (*PictureModel) Like

func (model *PictureModel) Like(params system.Params) error

func (*PictureModel) Remove

func (model *PictureModel) Remove(objectId string) (err error)

func (*PictureModel) Unlike

func (model *PictureModel) Unlike(params system.Params) error

type UserData

type UserData struct {
	Id          bson.ObjectId `bson:"_id" json:"id"`
	Username    string        `bson:"username" json:"username"`
	DisplayName string        `bson:"display_name" json:"display_name"`
	Email       string        `bson:"email" json:"email"`
	Password    string        `bson:"password" json:"-"`
}

func NewUserData

func NewUserData() *UserData

type UserModel

type UserModel struct {
	MgoModel
}

func NewUserModel

func NewUserModel(collection string) *UserModel

func (*UserModel) Auth

func (model *UserModel) Auth(params system.Params) (user *UserData, err error)

func (*UserModel) Create

func (model *UserModel) Create(params system.Params) (user *UserData, err error)

func (*UserModel) Edit

func (model *UserModel) Edit(params system.Params) (*UserData, error)

func (*UserModel) Find

func (model *UserModel) Find(objectId string) (user *UserData, err error)

func (*UserModel) FindByEmail

func (model *UserModel) FindByEmail(email string) (user *UserData, err error)

func (*UserModel) GetAlbums

func (model *UserModel) GetAlbums(objectId string, public bool) (albums []*AlbumData, err error)

func (*UserModel) SearchByUsername

func (model *UserModel) SearchByUsername(username string) (users []*UserData, err error)

Jump to

Keyboard shortcuts

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