diff options
Diffstat (limited to 'internal/db')
-rw-r--r-- | internal/db/db.go | 29 | ||||
-rw-r--r-- | internal/db/error.go (renamed from internal/db/actions.go) | 28 | ||||
-rw-r--r-- | internal/db/params.go | 30 |
3 files changed, 43 insertions, 44 deletions
diff --git a/internal/db/db.go b/internal/db/db.go index ea6f808cf..31a8ba5d9 100644 --- a/internal/db/db.go +++ b/internal/db/db.go @@ -30,34 +30,10 @@ const ( DBTypePostgres string = "POSTGRES" ) -// ErrNoEntries is to be returned from the DB interface when no entries are found for a given query. -type ErrNoEntries struct{} - -func (e ErrNoEntries) Error() string { - return "no entries" -} - -// ErrAlreadyExists is to be returned from the DB interface when an entry already exists for a given query or its constraints. -type ErrAlreadyExists struct{} - -func (e ErrAlreadyExists) Error() string { - return "already exists" -} - -type Where struct { - Key string - Value interface{} - CaseInsensitive bool -} - // DB provides methods for interacting with an underlying database or other storage mechanism (for now, just postgres). // Note that in all of the functions below, the passed interface should be a pointer or a slice, which will then be populated // by whatever is returned from the database. type DB interface { - // Federation returns an interface that's compatible with go-fed, for performing federation storage/retrieval functions. - // See: https://pkg.go.dev/github.com/go-fed/activity@v1.0.0/pub?utm_source=gopls#Database - // Federation() federatingdb.FederatingDB - /* BASIC DB FUNCTIONALITY */ @@ -269,10 +245,6 @@ type DB interface { // StatusBookmarkedBy checks if a given status has been bookmarked by a given account ID StatusBookmarkedBy(status *gtsmodel.Status, accountID string) (bool, error) - // FaveStatus faves the given status, using accountID as the faver. - // The returned fave will be nil if the status was already faved. - // FaveStatus(status *gtsmodel.Status, accountID string) (*gtsmodel.StatusFave, error) - // UnfaveStatus unfaves the given status, using accountID as the unfaver (sure, that's a word). // The returned fave will be nil if the status was already not faved. UnfaveStatus(status *gtsmodel.Status, accountID string) (*gtsmodel.StatusFave, error) @@ -285,6 +257,7 @@ type DB interface { // It will use the given filters and try to return as many statuses up to the limit as possible. GetHomeTimelineForAccount(accountID string, maxID string, sinceID string, minID string, limit int, local bool) ([]*gtsmodel.Status, error) + // GetNotificationsForAccount returns a list of notifications that pertain to the given accountID. GetNotificationsForAccount(accountID string, limit int, maxID string) ([]*gtsmodel.Notification, error) /* diff --git a/internal/db/actions.go b/internal/db/error.go index 4288f5fdb..197c7bd68 100644 --- a/internal/db/actions.go +++ b/internal/db/error.go @@ -18,20 +18,16 @@ package db -import ( - "context" - - "github.com/sirupsen/logrus" - "github.com/superseriousbusiness/gotosocial/internal/action" - "github.com/superseriousbusiness/gotosocial/internal/config" -) - -// Initialize will initialize the database given in the config for use with GoToSocial -var Initialize action.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { - // db, err := New(ctx, c, log) - // if err != nil { - // return err - // } - return nil - // return db.CreateSchema(ctx) +// ErrNoEntries is to be returned from the DB interface when no entries are found for a given query. +type ErrNoEntries struct{} + +func (e ErrNoEntries) Error() string { + return "no entries" +} + +// ErrAlreadyExists is to be returned from the DB interface when an entry already exists for a given query or its constraints. +type ErrAlreadyExists struct{} + +func (e ErrAlreadyExists) Error() string { + return "already exists" } diff --git a/internal/db/params.go b/internal/db/params.go new file mode 100644 index 000000000..f0c384435 --- /dev/null +++ b/internal/db/params.go @@ -0,0 +1,30 @@ +/* + GoToSocial + Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +package db + +// Where allows the caller of the DB to specify Where parameters. +type Where struct { + // The table to search on. + Key string + // The value that must be set. + Value interface{} + // Whether the value (if a string) should be case sensitive or not. + // Defaults to false. + CaseInsensitive bool +} |