Documentation ¶
Overview ¶
Package db provide interfaces which provide generalized operations on databases.
Index ¶
- Variables
- type Account
- func (a Account) Collection() Collection
- func (a Account) ConfigureCollection() error
- func (a Account) Create(account auth.Account) error
- func (a Account) Fetch(id bson.ObjectId) (*auth.Account, error)
- func (a Account) FindByEmail(email string) (*auth.Account, error)
- func (a Account) FindByUsername(name string) (*auth.Account, error)
- type Collection
- type DAO
- type Database
- type Project
- func (p Project) Collection() Collection
- func (p Project) ConfigureCollection() error
- func (p Project) Create(project project.Project) error
- func (p Project) CreateVersionFrom(existingVersionID VersionID) (project.Version, error)
- func (p Project) CreateVersionFromLatest(projectID ProjectID) (project.Version, error)
- func (p Project) Delete(projectID ProjectID) error
- func (p Project) EnsureSingleEditableVersion(projectID ProjectID) error
- func (p Project) Fetch(projectID ProjectID) (project.Project, error)
- func (p Project) FetchVersion(versionID VersionID) (project.Version, error)
- func (p Project) FetchVersionStatus(versionID VersionID) (project.VersionStatus, error)
- func (p Project) FindAllByAccountID(accountID bson.ObjectId) (project.List, error)
- func (p Project) SetVersionStatus(versionID VersionID, newStatus project.VersionStatus) error
- func (p Project) Update(project project.Project) error
- func (p Project) UpdateVersion(versionID VersionID, newSettings project.Settings) error
- func (p Project) UpdateVersionTimestamp(versionID VersionID) error
- type ProjectID
- type Result
- func (s Result) Collection() Collection
- func (s Result) ConfigureCollection() error
- func (s Result) Create(result result.Result) (bson.ObjectId, error)
- func (s Result) Delete(versionID VersionID) error
- func (s Result) Fetch(versionID VersionID) (result.Result, error)
- func (s Result) Update(versionID VersionID, result result.Result) error
- type Session
- type Setup
- func (s Setup) Collection() Collection
- func (s Setup) ConfigureCollection() error
- func (s Setup) Create(setup setup.Setup) (bson.ObjectId, error)
- func (s Setup) Delete(versionID VersionID) error
- func (s Setup) Fetch(versionID VersionID) (setup.Setup, error)
- func (s Setup) Update(versionID VersionID, setup setup.Setup) error
- type VersionID
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = mgo.ErrNotFound
ErrNotFound error is returned, when CRUD method can not find query result.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
Account collection DAO.
func (Account) Collection ¶
func (a Account) Collection() Collection
Collection implementation of DAO interface.
func (Account) ConfigureCollection ¶
ConfigureCollection implementation of DAO interface.
func (Account) Create ¶
Create create new account in Account collection. Return err, if any db error occurs.
func (Account) Fetch ¶
Fetch return auth.Account from db by id. Return nil, if not found. Return err, if any db error occurs.
func (Account) FindByEmail ¶
FindByEmail return if exists user with email @email.
type Collection ¶
type Collection interface { Find(query interface{}) *mgo.Query Count() (n int, err error) FindId(id interface{}) *mgo.Query Insert(docs ...interface{}) error Remove(selector interface{}) error Update(selector interface{}, update interface{}) error Upsert(selector interface{}, update interface{}) (info *mgo.ChangeInfo, err error) EnsureIndex(index mgo.Index) error RemoveAll(selector interface{}) (info *mgo.ChangeInfo, err error) }
Collection is the interface implemented by types that can perform database CRUD operations.
type DAO ¶
type DAO interface { // ConfigureCollection configure collection configuration such as Indexes. ConfigureCollection() error Collection() Collection }
DAO represent collection DAO.
type Database ¶
type Database interface {
C(name string) Collection
}
Database provide access to Database Collection.
type Project ¶
type Project struct {
// contains filtered or unexported fields
}
Project collection DAO.
func (Project) Collection ¶
func (p Project) Collection() Collection
Collection implementation of DAO interface.
func (Project) ConfigureCollection ¶
ConfigureCollection implementation of DAO interface.
func (Project) CreateVersionFrom ¶
CreateVersionFrom works like CreateVersion, but childs are copied from existingVersion childs. Return nil, if version not found. Return err, if any db error occurs.
func (Project) CreateVersionFromLatest ¶
CreateVersionFromLatest creates version from latest.
func (Project) Delete ¶
Delete remove project.Project from db. Return db.ErrorNotFound, if project does not exists in db. Return another err, if any other db error occurs.
func (Project) EnsureSingleEditableVersion ¶
EnsureSingleEditableVersion ensures that last version is only editable.
func (Project) FetchVersion ¶
FetchVersion find project.Version. Return nil, if not found. Return err, if any db error occurs.
func (Project) FetchVersionStatus ¶
func (p Project) FetchVersionStatus(versionID VersionID) (project.VersionStatus, error)
FetchVersionStatus fetch VersionStatus.
func (Project) FindAllByAccountID ¶
FindAllByAccountID return project.List, which contains all projects of accountID Account. Return err, if any db error occurs.
func (Project) SetVersionStatus ¶
func (p Project) SetVersionStatus(versionID VersionID, newStatus project.VersionStatus) error
SetVersionStatus sets new VersionStatus.
func (Project) Update ¶
Update update project.Project. Return db.ErrorNotFound, if project does not exists in db. Return another err, if any other db error occurs.
func (Project) UpdateVersion ¶
UpdateVersion update version with the given versionID.
func (Project) UpdateVersionTimestamp ¶
UpdateVersionTimestamp update version with the given versionID.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result ocollection DAO.
func (Result) Collection ¶
func (s Result) Collection() Collection
Collection implementation of DAO interface.
func (Result) ConfigureCollection ¶
ConfigureCollection implementation of DAO interface.
func (Result) Create ¶
Create Result in db, and return ObjectId of created document. Return err, if any db error occurs.
func (Result) Delete ¶
Delete remove *result.Resultd from db. Return db.ErrorNotFound, if result does not exists in db. Return another err, if any other db error occurs.
type Session ¶
type Session interface { // Copy copy Session handler. // Copy is necessary, if you need perfom db operations on several goroutines at once. Copy() Session //Close close Session. Close() DB() Database Account() Account Project() Project Setup() Setup Result() Result // Configure configure db and collections. Configure() error }
Session represents a communication session with the database.
type Setup ¶
type Setup struct {
// contains filtered or unexported fields
}
Setup ocollection DAO.
func (Setup) Collection ¶
func (s Setup) Collection() Collection
Collection implementation of DAO interface.
func (Setup) ConfigureCollection ¶
ConfigureCollection implementation of DAO interface.
func (Setup) Create ¶
Create Setup in db, and return ObjectId of created document. Return err, if any db error occurs.
func (Setup) Delete ¶
Delete remove *setup.Setupd from db. Return db.ErrorNotFound, if setup does not exists in db. Return another err, if any other db error occurs.