Documentation
¶
Index ¶
- func Setup(opts r.ConnectOpts) error
- type AccountsTable
- func (users *AccountsTable) FindAccountByName(name string) (*models.Account, error)
- func (users *AccountsTable) GetAccount(id string) (*models.Account, error)
- func (a *AccountsTable) GetTokenOwner(token *models.Token) (*models.Account, error)
- func (a *AccountsTable) IsEmailUsed(email string) (bool, error)
- func (a *AccountsTable) IsUsernameUsed(name string) (bool, error)
- type AddressesTable
- type ContactsTable
- type DatabaseError
- type Default
- func (d *Default) Delete(pred interface{}) error
- func (d *Default) DeleteID(id string) error
- func (d *Default) Find(id string) (*gorethink.Cursor, error)
- func (d *Default) FindBy(key string, value interface{}) (*gorethink.Cursor, error)
- func (d *Default) FindByAndCount(key string, value interface{}) (int, error)
- func (d *Default) FindByAndFetch(key string, value interface{}, results interface{}) error
- func (d *Default) FindByAndFetchOne(key string, value interface{}, result interface{}) error
- func (d *Default) FindByIndex(index string, values ...interface{}) (*gorethink.Cursor, error)
- func (d *Default) FindByIndexFetch(results interface{}, index string, values ...interface{}) error
- func (d *Default) FindByIndexFetchOne(result interface{}, index string, values ...interface{}) error
- func (d *Default) FindFetchOne(id string, value interface{}) error
- func (d *Default) GetDBName() string
- func (d *Default) GetSession() *gorethink.Session
- func (d *Default) GetTable() gorethink.Term
- func (d *Default) GetTableName() string
- func (d *Default) Insert(data interface{}) error
- func (d *Default) Update(data interface{}) error
- func (d *Default) UpdateID(id string, data interface{}) error
- func (d *Default) Where(filter map[string]interface{}) (*gorethink.Cursor, error)
- func (d *Default) WhereAndFetch(filter map[string]interface{}, results interface{}) error
- func (d *Default) WhereAndFetchOne(filter map[string]interface{}, result interface{}) error
- type EmailsTable
- func (e *EmailsTable) CountOwnedBy(id string) (int, error)
- func (e *EmailsTable) DeleteByThread(id string) error
- func (e *EmailsTable) DeleteOwnedBy(id string) error
- func (e *EmailsTable) GetByThread(thread string) ([]*models.Email, error)
- func (e *EmailsTable) GetEmail(id string) (*models.Email, error)
- func (e *EmailsTable) GetOwnedBy(id string) ([]*models.Email, error)
- func (e *EmailsTable) GetThreadManifest(thread string) (string, error)
- func (e *EmailsTable) List(owner string, sort []string, offset int, limit int, thread string) ([]*models.Email, error)
- type FilesTable
- func (f *FilesTable) CountByEmail(id string) (int, error)
- func (f *FilesTable) DeleteOwnedBy(id string) error
- func (f *FilesTable) GetEmailFiles(id string) ([]*models.File, error)
- func (f *FilesTable) GetFile(id string) (*models.File, error)
- func (f *FilesTable) GetFiles(ids ...string) ([]*models.File, error)
- func (f *FilesTable) GetInEmail(owner string, email string, name string) ([]*models.File, error)
- func (f *FilesTable) GetOwnedBy(id string) ([]*models.File, error)
- type KeysTable
- type LabelsTable
- func (l *LabelsTable) Delete(cond interface{}) error
- func (l *LabelsTable) DeleteID(id string) error
- func (l *LabelsTable) GetLabel(id string) (*models.Label, error)
- func (l *LabelsTable) GetLabelByNameAndOwner(owner string, name string) (*models.Label, error)
- func (l *LabelsTable) GetOwnedBy(id string) ([]*models.Label, error)
- func (l *LabelsTable) Insert(data interface{}) error
- func (l *LabelsTable) Update(data interface{}) error
- func (l *LabelsTable) UpdateID(id string, data interface{}) error
- type ReservationsTable
- type RethinkCRUD
- type RethinkCreator
- type RethinkDeleter
- type RethinkReader
- type RethinkTable
- type RethinkUpdater
- type ThreadsTable
- func (t *ThreadsTable) CountByLabel(label string) (int, error)
- func (t *ThreadsTable) CountByLabelUnread(label string) (int, error)
- func (t *ThreadsTable) CountOwnedBy(id string) (int, error)
- func (t *ThreadsTable) DeleteOwnedBy(id string) error
- func (t *ThreadsTable) GetByLabel(label string) ([]*models.Thread, error)
- func (t *ThreadsTable) GetOwnedBy(id string) ([]*models.Thread, error)
- func (t *ThreadsTable) GetThread(id string) (*models.Thread, error)
- func (t *ThreadsTable) List(owner string, sort []string, offset int, limit int, labels []string) ([]*models.Thread, error)
- type TokensTable
- func (t *TokensTable) Delete(cond interface{}) error
- func (t *TokensTable) DeleteID(id string) error
- func (t *TokensTable) DeleteOwnedBy(id string) error
- func (t *TokensTable) FindFetchOne(id string, value interface{}) error
- func (t *TokensTable) GetToken(id string) (*models.Token, error)
- func (t *TokensTable) Insert(data interface{}) error
- func (t *TokensTable) Update(data interface{}) error
- func (t *TokensTable) UpdateID(id string, data interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccountsTable ¶
type AccountsTable struct { RethinkCRUD Tokens *TokensTable }
AccountsTable implements the CRUD interface for accounts
func (*AccountsTable) FindAccountByName ¶
func (users *AccountsTable) FindAccountByName(name string) (*models.Account, error)
FindAccountByName returns an account with specified name
func (*AccountsTable) GetAccount ¶
func (users *AccountsTable) GetAccount(id string) (*models.Account, error)
GetAccount returns an account with specified ID
func (*AccountsTable) GetTokenOwner ¶
func (*AccountsTable) IsEmailUsed ¶
func (a *AccountsTable) IsEmailUsed(email string) (bool, error)
func (*AccountsTable) IsUsernameUsed ¶
func (a *AccountsTable) IsUsernameUsed(name string) (bool, error)
type AddressesTable ¶
type AddressesTable struct {
RethinkCRUD
}
func (*AddressesTable) DeleteOwnedBy ¶
func (a *AddressesTable) DeleteOwnedBy(id string) error
func (*AddressesTable) GetAddress ¶
func (a *AddressesTable) GetAddress(id string) (*models.Address, error)
func (*AddressesTable) GetOwnedBy ¶
func (a *AddressesTable) GetOwnedBy(id string) ([]*models.Address, error)
type ContactsTable ¶
type ContactsTable struct {
RethinkCRUD
}
Contacts implements the CRUD interface for tokens
func (*ContactsTable) DeleteOwnedBy ¶
func (c *ContactsTable) DeleteOwnedBy(id string) error
DeleteOwnedBy deletes all contacts owned by id
func (*ContactsTable) GetContact ¶
func (c *ContactsTable) GetContact(id string) (*models.Contact, error)
GetContact returns a token with specified name
func (*ContactsTable) GetOwnedBy ¶
func (c *ContactsTable) GetOwnedBy(id string) ([]*models.Contact, error)
GetOwnedBy returns all contacts owned by id
type DatabaseError ¶
type DatabaseError struct {
// contains filtered or unexported fields
}
DatabaseError is the wrapper for RethinkDB errors that allows passing more data with the message
func NewDatabaseError ¶
func NewDatabaseError(t RethinkTable, err error, message string) *DatabaseError
NewDatabaseError creates a new DatabaseError, wraps err and adds a message
func (*DatabaseError) Error ¶
func (d *DatabaseError) Error() string
type Default ¶
type Default struct {
// contains filtered or unexported fields
}
Default contains the basic implementation of the gorethinkCRUD interface
func NewCRUDTable ¶
NewCRUDTable sets up a new Default struct
func (*Default) FindBy ¶
FindBy is an utility for fetching values if they are stored in a key-value manenr.
func (*Default) FindByAndCount ¶
func (*Default) FindByAndFetch ¶
FindByAndFetch retrieves a value by key and then fills results with the result.
func (*Default) FindByAndFetchOne ¶
FindByAndFetchOne retrieves a value by key and then fills result with the first row of the result
func (*Default) FindByIndex ¶
FindByIndex filters all resources whose index is matching
func (*Default) FindByIndexFetch ¶
FindByIndexFetch filters all resources whose index is matching and fills results with all found resources
func (*Default) FindByIndexFetchOne ¶
func (d *Default) FindByIndexFetchOne(result interface{}, index string, values ...interface{}) error
FindByIndexFetchOne filters all resources whose index is matching and fills result with the first one found
func (*Default) FindFetchOne ¶
FindFetchOne searches for a resource and then unmarshals the first row into value
func (*Default) GetSession ¶
GetSession returns the current session
func (*Default) GetTableName ¶
GetTableName returns table's name
func (*Default) UpdateID ¶
UpdateID performs an update on an existing resource with ID that equals the id argument
func (*Default) WhereAndFetch ¶
WhereAndFetch filters with multiple fields and then fills results with all found resources
func (*Default) WhereAndFetchOne ¶
WhereAndFetchOne filters with multiple fields and then fills result with the first found resource
type EmailsTable ¶
type EmailsTable struct {
RethinkCRUD
}
Emails implements the CRUD interface for tokens
func (*EmailsTable) CountOwnedBy ¶
func (e *EmailsTable) CountOwnedBy(id string) (int, error)
func (*EmailsTable) DeleteByThread ¶
func (e *EmailsTable) DeleteByThread(id string) error
func (*EmailsTable) DeleteOwnedBy ¶
func (e *EmailsTable) DeleteOwnedBy(id string) error
DeleteOwnedBy deletes all emails owned by id
func (*EmailsTable) GetByThread ¶
func (e *EmailsTable) GetByThread(thread string) ([]*models.Email, error)
func (*EmailsTable) GetEmail ¶
func (e *EmailsTable) GetEmail(id string) (*models.Email, error)
GetEmail returns a token with specified name
func (*EmailsTable) GetOwnedBy ¶
func (e *EmailsTable) GetOwnedBy(id string) ([]*models.Email, error)
GetOwnedBy returns all emails owned by id
func (*EmailsTable) GetThreadManifest ¶
func (e *EmailsTable) GetThreadManifest(thread string) (string, error)
type FilesTable ¶
type FilesTable struct { RethinkCRUD Emails *EmailsTable }
func (*FilesTable) CountByEmail ¶
func (f *FilesTable) CountByEmail(id string) (int, error)
func (*FilesTable) DeleteOwnedBy ¶
func (f *FilesTable) DeleteOwnedBy(id string) error
func (*FilesTable) GetEmailFiles ¶
func (f *FilesTable) GetEmailFiles(id string) ([]*models.File, error)
func (*FilesTable) GetInEmail ¶
func (*FilesTable) GetOwnedBy ¶
func (f *FilesTable) GetOwnedBy(id string) ([]*models.File, error)
type LabelsTable ¶
type LabelsTable struct { RethinkCRUD Emails *EmailsTable //Cache cache.Cache Expires time.Duration }
func (*LabelsTable) Delete ¶
func (l *LabelsTable) Delete(cond interface{}) error
Delete removes from db and cache using filter
func (*LabelsTable) DeleteID ¶
func (l *LabelsTable) DeleteID(id string) error
DeleteID removes from db and cache using id query
func (*LabelsTable) GetLabelByNameAndOwner ¶
func (*LabelsTable) GetOwnedBy ¶
func (l *LabelsTable) GetOwnedBy(id string) ([]*models.Label, error)
GetOwnedBy returns all labels owned by id
func (*LabelsTable) Insert ¶
func (l *LabelsTable) Insert(data interface{}) error
func (*LabelsTable) Update ¶
func (l *LabelsTable) Update(data interface{}) error
Update clears all updated keys
func (*LabelsTable) UpdateID ¶
func (l *LabelsTable) UpdateID(id string, data interface{}) error
UpdateID updates the specified label and updates cache
type ReservationsTable ¶
type ReservationsTable struct {
RethinkCRUD
}
ReservationsTable is a CRUD interface for accessing the "reservation" table
func (*ReservationsTable) IsEmailUsed ¶
func (r *ReservationsTable) IsEmailUsed(email string) (bool, error)
func (*ReservationsTable) IsUsernameUsed ¶
func (r *ReservationsTable) IsUsernameUsed(name string) (bool, error)
type RethinkCRUD ¶
type RethinkCRUD interface { RethinkCreator RethinkReader RethinkUpdater RethinkDeleter RethinkTable }
RethinkCRUD is the interface that every table should implement
type RethinkCreator ¶
type RethinkCreator interface {
Insert(data interface{}) error
}
RethinkCreator contains a function to create new instances in the table
type RethinkDeleter ¶
RethinkDeleter allows deleting resources from the database
type RethinkReader ¶
type RethinkReader interface { Find(id string) (*gorethink.Cursor, error) FindFetchOne(id string, value interface{}) error FindBy(key string, value interface{}) (*gorethink.Cursor, error) FindByAndFetch(key string, value interface{}, results interface{}) error FindByAndFetchOne(key string, value interface{}, result interface{}) error FindByAndCount(key string, value interface{}) (int, error) Where(filter map[string]interface{}) (*gorethink.Cursor, error) WhereAndFetch(filter map[string]interface{}, results interface{}) error WhereAndFetchOne(filter map[string]interface{}, result interface{}) error FindByIndex(index string, values ...interface{}) (*gorethink.Cursor, error) FindByIndexFetch(results interface{}, index string, values ...interface{}) error FindByIndexFetchOne(result interface{}, index string, values ...interface{}) error }
RethinkReader allows fetching resources from the database
type RethinkTable ¶
type RethinkTable interface { GetTableName() string GetDBName() string GetTable() gorethink.Term GetSession() *gorethink.Session }
RethinkTable contains the most basic table functions
type RethinkUpdater ¶
type RethinkUpdater interface { Update(data interface{}) error UpdateID(id string, data interface{}) error }
RethinkUpdater allows updating existing resources in the database
type ThreadsTable ¶
type ThreadsTable struct {
RethinkCRUD
}
func (*ThreadsTable) CountByLabel ¶
func (t *ThreadsTable) CountByLabel(label string) (int, error)
func (*ThreadsTable) CountByLabelUnread ¶
func (t *ThreadsTable) CountByLabelUnread(label string) (int, error)
func (*ThreadsTable) CountOwnedBy ¶
func (t *ThreadsTable) CountOwnedBy(id string) (int, error)
func (*ThreadsTable) DeleteOwnedBy ¶
func (t *ThreadsTable) DeleteOwnedBy(id string) error
func (*ThreadsTable) GetByLabel ¶
func (t *ThreadsTable) GetByLabel(label string) ([]*models.Thread, error)
func (*ThreadsTable) GetOwnedBy ¶
func (t *ThreadsTable) GetOwnedBy(id string) ([]*models.Thread, error)
type TokensTable ¶
type TokensTable struct { RethinkCRUD Cache cache.Cache Expires time.Duration }
TokensTable implements the CRUD interface for tokens
func (*TokensTable) Delete ¶
func (t *TokensTable) Delete(cond interface{}) error
Delete removes from db and cache using filter
func (*TokensTable) DeleteID ¶
func (t *TokensTable) DeleteID(id string) error
DeleteID removes from db and cache using id query
func (*TokensTable) DeleteOwnedBy ¶
func (t *TokensTable) DeleteOwnedBy(id string) error
DeleteOwnedBy deletes all tokens owned by id
func (*TokensTable) FindFetchOne ¶
func (t *TokensTable) FindFetchOne(id string, value interface{}) error
FindFetchOne tries cache and then tries using DefaultCRUD's fetch operation
func (*TokensTable) GetToken ¶
func (t *TokensTable) GetToken(id string) (*models.Token, error)
GetToken returns a token with specified name
func (*TokensTable) Insert ¶
func (t *TokensTable) Insert(data interface{}) error
Insert monkey-patches the DefaultCRUD method and introduces caching
func (*TokensTable) Update ¶
func (t *TokensTable) Update(data interface{}) error
Update clears all updated keys
func (*TokensTable) UpdateID ¶
func (t *TokensTable) UpdateID(id string, data interface{}) error
UpdateID updates the specified token and updates cache