daos

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2018 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToAbsMediaPath

func ToAbsMediaPath(item *models.Media) *models.Media

ToAbsMediaPath converts single media item path to absolute url by prefixing each item's `Path` property with the application base url.

func ToAbsMediaPaths

func ToAbsMediaPaths(items []models.Media) []models.Media

ToAbsMediaPaths converts multiple media item paths to absolute urls by prefixing each item's `Path` property with the application base url.

Types

type CollectionDAO

type CollectionDAO struct {
	Session    *mgo.Session
	Collection string
}

CollectionDAO gets and persists collection data in database.

func NewCollectionDAO

func NewCollectionDAO(session *mgo.Session) *CollectionDAO

NewCollectionDAO creates a new CollectionDAO.

func (*CollectionDAO) Count

func (dao *CollectionDAO) Count(conditions bson.M) (int, error)

Count returns the total number of collection models based on the provided conditions.

func (*CollectionDAO) Create

func (dao *CollectionDAO) Create(form *models.CollectionForm) (*models.Collection, error)

Create inserts and returns a new collection model.

func (*CollectionDAO) Delete

func (dao *CollectionDAO) Delete(model *models.Collection) error

Delete deletes single collection model by its id.

func (*CollectionDAO) GetByID

func (dao *CollectionDAO) GetByID(id string, additionalConditions ...bson.M) (*models.Collection, error)

GetByID returns single collection model by its id hex.

func (*CollectionDAO) GetByName

func (dao *CollectionDAO) GetByName(name string, additionalConditions ...bson.M) (*models.Collection, error)

GetByName returns single collection model by its name.

func (*CollectionDAO) GetByNameOrID

func (dao *CollectionDAO) GetByNameOrID(prop string, additionalConditions ...bson.M) (*models.Collection, error)

GetByNameOrID returns single collection model by its id hex or name.

func (*CollectionDAO) GetList

func (dao *CollectionDAO) GetList(limit int, offset int, conditions bson.M, sortData []string) ([]models.Collection, error)

GetList returns list with collection models.

func (*CollectionDAO) GetOne

func (dao *CollectionDAO) GetOne(conditions bson.M) (*models.Collection, error)

GetOne returns single collection model based on the provided conditions.

func (*CollectionDAO) Update

func (dao *CollectionDAO) Update(form *models.CollectionForm) (*models.Collection, error)

Update updates and returns existing collection model.

type EntityDAO

type EntityDAO struct {
	Session    *mgo.Session
	Collection string
}

EntityDAO gets and persists entity data in database.

func NewEntityDAO

func NewEntityDAO(session *mgo.Session) *EntityDAO

NewEntityDAO creates a new EntityDAO.

func (*EntityDAO) Count

func (dao *EntityDAO) Count(conditions bson.M) (int, error)

Count returns the total number of Entity models based on the provided conditions.

func (*EntityDAO) Create

func (dao *EntityDAO) Create(form *models.EntityForm) (*models.Entity, error)

Create inserts and returns a new entity model.

func (*EntityDAO) Delete

func (dao *EntityDAO) Delete(model *models.Entity) error

Delete deletes the provided entity model.

func (*EntityDAO) DeleteAll

func (dao *EntityDAO) DeleteAll(conditions bson.M) error

DeleteAll deletes all entities by the provided conditions.

func (*EntityDAO) EnrichEntities

func (dao *EntityDAO) EnrichEntities(
	entities []models.Entity,
	collection *models.Collection,
	settings *EntityEnrichSettings,
) []models.Entity

EnrichEntities enriches entity relation and media data fields.

func (*EntityDAO) EnrichEntitiesByCollectionName

func (dao *EntityDAO) EnrichEntitiesByCollectionName(
	entities []models.Entity,
	collectionName string,
	settings *EntityEnrichSettings,
) []models.Entity

EnrichEntitiesByCollectionName enriches entity relation and media data fields. by providing `Collection.Name` instead of `Collection` model.

func (*EntityDAO) EnrichEntity

func (dao *EntityDAO) EnrichEntity(entity *models.Entity, collection *models.Collection, settings *EntityEnrichSettings) *models.Entity

EnrichEntities enriches single entity model relation and media data fields.

func (*EntityDAO) EnrichEntityByCollectionName

func (dao *EntityDAO) EnrichEntityByCollectionName(
	entity *models.Entity,
	collectionName string,
	settings *EntityEnrichSettings,
) *models.Entity

EnrichEntityByCollectionName enriches single entity model relation and media data fields by providing `Collection.Name` instead of `Collection` model.

func (*EntityDAO) GetByID

func (dao *EntityDAO) GetByID(id string, additionalConditions ...bson.M) (*models.Entity, error)

GetByID returns single entity by its id.

func (*EntityDAO) GetByIdAndCollection

func (dao *EntityDAO) GetByIdAndCollection(id string, collectionProp string, additionalConditions ...bson.M) (*models.Entity, error)

GetByIdAndCollection returns single entity by its id and collection identifier (id or name).

func (*EntityDAO) GetEntityCollection

func (dao *EntityDAO) GetEntityCollection(entity *models.Entity) (*models.Collection, error)

GetEntityCollection returns the collection model related to an entity.

func (*EntityDAO) GetList

func (dao *EntityDAO) GetList(limit int, offset int, conditions bson.M, sortData []string) ([]models.Entity, error)

GetList returns list with Entity models.

func (*EntityDAO) GetOne

func (dao *EntityDAO) GetOne(conditions bson.M) (*models.Entity, error)

GetOne returns single entity based on the provided conditions.

func (*EntityDAO) InitDataLocale

func (dao *EntityDAO) InitDataLocale(locale string, defaultLocale string) error

InitDataLocale creates new data locale group entry by copying the default locale group fields.

func (*EntityDAO) RemoveDataLocale

func (dao *EntityDAO) RemoveDataLocale(locale string) error

RemoveDataLocale removes data locale group of multiple entity model.

func (*EntityDAO) RenameDataLocale

func (dao *EntityDAO) RenameDataLocale(oldLocale string, newLocale string) error

RenameDataLocale renames data locale group of multiple entity models.

func (*EntityDAO) Update

func (dao *EntityDAO) Update(form *models.EntityForm) (*models.Entity, error)

Update updates and returns existing entity model.

type EntityEnrichSettings

type EntityEnrichSettings struct {
	Level            int
	EnrichMedia      bool
	RelCollectionIds []bson.ObjectId
	RelConditions    bson.M
	MediaConditions  bson.M
}

type KeyDAO

type KeyDAO struct {
	Session    *mgo.Session
	Collection string
}

KeyDAO gets and persists Key data in database.

func NewKeyDAO

func NewKeyDAO(session *mgo.Session) *KeyDAO

NewKeyDAO creates a new KeyDAO.

func (*KeyDAO) Count

func (dao *KeyDAO) Count(conditions bson.M) (int, error)

Count returns the total number of Key models based on the provided conditions.

func (*KeyDAO) Create

func (dao *KeyDAO) Create(form *models.KeyForm) (*models.Key, error)

Create inserts and returns a new Key model.

func (*KeyDAO) Delete

func (dao *KeyDAO) Delete(model *models.Key) error

Delete deletes the provided Key model.

func (*KeyDAO) GetByID

func (dao *KeyDAO) GetByID(id string, additionalConditions ...bson.M) (*models.Key, error)

GetByID returns single Key model by its id hex string.

func (*KeyDAO) GetList

func (dao *KeyDAO) GetList(limit int, offset int, conditions bson.M, sortData []string) ([]models.Key, error)

GetList returns list with Key models.

func (*KeyDAO) GetOne

func (dao *KeyDAO) GetOne(conditions bson.M) (*models.Key, error)

GetOne returns single Key model based on the provided conditions.

func (*KeyDAO) SetAccessGroup

func (dao *KeyDAO) SetAccessGroup(group string, actions ...string) error

SetAccessGroup sets new access group to all available keys.

func (*KeyDAO) UnsetAccessGroup

func (dao *KeyDAO) UnsetAccessGroup(group string) error

UnsetAccessGroup unsets access group from all available keys.

func (*KeyDAO) Update

func (dao *KeyDAO) Update(form *models.KeyForm) (*models.Key, error)

Update updates and returns existing Key model.

type LanguageDAO

type LanguageDAO struct {
	Session    *mgo.Session
	Collection string
}

LanguageDAO gets and persists language data in database.

func NewLanguageDAO

func NewLanguageDAO(session *mgo.Session) *LanguageDAO

NewLanguageDAO creates a new LanguageDAO.

func (*LanguageDAO) Count

func (dao *LanguageDAO) Count(conditions bson.M) (int, error)

Count returns the total number of language models based on the provided conditions.

func (*LanguageDAO) Create

func (dao *LanguageDAO) Create(form *models.LanguageForm) (*models.Language, error)

Create inserts and returns a new language model.

func (*LanguageDAO) Delete

func (dao *LanguageDAO) Delete(model *models.Language) error

Delete deletes the provided language model.

func (*LanguageDAO) GetAll

func (dao *LanguageDAO) GetAll() ([]models.Language, error)

GetAll returns list with all language models.

func (*LanguageDAO) GetByID

func (dao *LanguageDAO) GetByID(id string, additionalConditions ...bson.M) (*models.Language, error)

GetByID returns single language model by its id.

func (*LanguageDAO) GetByLocale

func (dao *LanguageDAO) GetByLocale(locale string, additionalConditions ...bson.M) (*models.Language, error)

GetByLocale returns single language model by its locale.

func (*LanguageDAO) GetList

func (dao *LanguageDAO) GetList(limit int, offset int, conditions bson.M, sortData []string) ([]models.Language, error)

GetList returns list with language models.

func (*LanguageDAO) GetOne

func (dao *LanguageDAO) GetOne(conditions bson.M) (*models.Language, error)

GetOne returns single language model based on the provided conditions.

func (*LanguageDAO) Update

func (dao *LanguageDAO) Update(form *models.LanguageForm) (*models.Language, error)

Update updates and returns existing language model.

type MediaDAO

type MediaDAO struct {
	Session    *mgo.Session
	Collection string
}

MediaDAO gets and persists file data in database.

func NewMediaDAO

func NewMediaDAO(session *mgo.Session) *MediaDAO

NewMediaDAO creates a new MediaDAO.

func (*MediaDAO) Count

func (dao *MediaDAO) Count(conditions bson.M) (int, error)

Count returns the total number of media models based on the provided conditions.

func (*MediaDAO) Create

func (dao *MediaDAO) Create(model *models.Media) (*models.Media, error)

Create inserts and returns a new media model.

func (*MediaDAO) Delete

func (dao *MediaDAO) Delete(model *models.Media) error

Delete deletes the provided media model.

func (*MediaDAO) GetByID

func (dao *MediaDAO) GetByID(id string, additionalConditions ...bson.M) (*models.Media, error)

GetByID returns single media model by its id.

func (*MediaDAO) GetList

func (dao *MediaDAO) GetList(limit int, offset int, conditions bson.M, sortData []string) ([]models.Media, error)

GetList returns list with media models.

func (*MediaDAO) GetOne

func (dao *MediaDAO) GetOne(conditions bson.M) (*models.Media, error)

GetOne returns single media model based on the provided conditions.

func (*MediaDAO) Replace

func (dao *MediaDAO) Replace(model *models.Media) (*models.Media, error)

Replace replaces (aka. full update) existing media model record.

func (*MediaDAO) Update

func (dao *MediaDAO) Update(form *models.MediaUpdateForm) (*models.Media, error)

Update updates existing media model settings.

type UserDAO

type UserDAO struct {
	Session    *mgo.Session
	Collection string
}

UserDAO gets and persists user data in database.

func NewUserDAO

func NewUserDAO(session *mgo.Session) *UserDAO

NewUserDAO creates a new UserDAO.

func (*UserDAO) Authenticate

func (dao *UserDAO) Authenticate(username, password string) (*models.User, error)

Authenticate validates and returns active user model.

func (*UserDAO) Count

func (dao *UserDAO) Count(conditions bson.M) (int, error)

Count returns the total number of user models based on the provided conditions.

func (*UserDAO) Create

func (dao *UserDAO) Create(form *models.UserCreateForm) (*models.User, error)

Create inserts and returns a new user model.

func (*UserDAO) Delete

func (dao *UserDAO) Delete(model *models.User) error

Delete deletes the provided user model.

func (*UserDAO) GetByEmail

func (dao *UserDAO) GetByEmail(email string, additionalConditions ...bson.M) (*models.User, error)

GetByEmail returns single active user model by its email.

func (*UserDAO) GetByID

func (dao *UserDAO) GetByID(id string, additionalConditions ...bson.M) (*models.User, error)

GetByID returns single user model by its id.

func (*UserDAO) GetByUsername

func (dao *UserDAO) GetByUsername(username string, additionalConditions ...bson.M) (*models.User, error)

GetByUsername returns single active user model by its username.

func (*UserDAO) GetList

func (dao *UserDAO) GetList(limit int, offset int, conditions bson.M, sortData []string) ([]models.User, error)

GetList returns list with user models.

func (*UserDAO) GetOne

func (dao *UserDAO) GetOne(conditions bson.M) (*models.User, error)

GetOne returns single user model based on the provided conditions.

func (*UserDAO) RenewResetPasswordHash

func (dao *UserDAO) RenewResetPasswordHash(model *models.User) (*models.User, error)

RenewResetPasswordHash renews user reset password hash string.

func (*UserDAO) ResetPassword

func (dao *UserDAO) ResetPassword(form *models.UserResetPasswordForm) (*models.User, error)

ResetPassword resets and changes user's password.

func (*UserDAO) SetAccessGroup

func (dao *UserDAO) SetAccessGroup(group string, actions ...string) error

SetAccessGroup sets new access group to all available users.

func (*UserDAO) UnsetAccessGroup

func (dao *UserDAO) UnsetAccessGroup(group string) error

UnsetAccessGroup unsets/removes access group from all available users.

func (*UserDAO) Update

func (dao *UserDAO) Update(form *models.UserUpdateForm) (*models.User, error)

Update updates and returns existing user model.

Jump to

Keyboard shortcuts

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