diff options
author | Kevin Chabowski <kevin@kch42.de> | 2013-08-28 15:38:28 +0200 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2013-08-28 15:52:31 +0200 |
commit | 720b8752937c3ece802ce767aaf8ea7662798006 (patch) | |
tree | 1b4ebe1f58f5b860e7373c745ed9b13c3f5d3f3a /model | |
parent | fa85fb714847545afefd2659701d5ff01ea3a0a7 (diff) | |
download | mailremind-720b8752937c3ece802ce767aaf8ea7662798006.tar.gz mailremind-720b8752937c3ece802ce767aaf8ea7662798006.tar.bz2 mailremind-720b8752937c3ece802ce767aaf8ea7662798006.zip |
Improved database model
Diffstat (limited to 'model')
-rw-r--r-- | model/dbmodel.go | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/model/dbmodel.go b/model/dbmodel.go index 9dd2c91..76414c7 100644 --- a/model/dbmodel.go +++ b/model/dbmodel.go @@ -23,9 +23,16 @@ type User interface { PWHash() []byte SetPWHash([]byte) error - AddJob() Job + AddJob(subject string, content []byte, chron chronos.MultiChronos, next time.Time) (Job, error) Jobs() []Job JobByID(DBID) (Job, error) + CountJobs() int + + Active() bool + SetActive(bool) error + + ActivationCode() string + SetActivationCode(string) error Delete() error } @@ -40,8 +47,8 @@ type Job interface { Content() []byte SetContent([]byte) error - Chronos() []chronos.Chronos - SetChronos([]chronos.Chronos) error + Chronos() chronos.MultiChronos + SetChronos(chronos.MultiChronos) error Next() time.Time SetNext(time.Time) error @@ -55,10 +62,11 @@ type DBCon interface { UserByID(DBID) (User, error) UserByMail(string) (User, error) - LastAccess() time.Time - SetLastAccess(time.Time) error + AddUser(email string, pwhash []byte, location *time.Location, active bool, acCode string) (User, error) + + InactiveUsers(olderthan time.Time) []DBID - JobsBetween(a, b time.Time) ([]Job, error) + JobsBefore(t time.Time) []DBID // Get Jobs with next <= t } type DBInfo struct { @@ -81,3 +89,11 @@ func GetDBInfo(name string) (DBInfo, bool) { dbinfo, ok := dbinfos[name] return dbinfo, ok } + +func AllDatabases() []string { + names := make([]string, 0, len(dbinfos)) + for name := range dbinfos { + names = append(names, name) + } + return names +} |