Documentation ¶
Index ¶
- Constants
- type DB
- func (me *DB) AddEncryptKeyForPublicKey(u *charm.User, pk string, gid string, ek string, ca *time.Time) error
- func (me *DB) Close() error
- func (me *DB) CreateDB() error
- func (me *DB) DeleteToken(token charm.Token) error
- func (me *DB) EncryptKeysForPublicKey(pk *charm.PublicKey) ([]*charm.EncryptKey, error)
- func (me *DB) GetNews(id string) (*charm.News, error)
- func (me *DB) GetNewsList(tag string, page int) ([]*charm.News, error)
- func (me *DB) GetSeq(u *charm.User, name string) (uint64, error)
- func (me *DB) GetUserWithID(charmID string) (*charm.User, error)
- func (me *DB) GetUserWithName(name string) (*charm.User, error)
- func (me *DB) KeysForUser(user *charm.User) ([]*charm.PublicKey, error)
- func (me *DB) LinkUserKey(user *charm.User, key string) error
- func (me *DB) MergeUsers(userID1 int, userID2 int) error
- func (me *DB) NextSeq(u *charm.User, name string) (uint64, error)
- func (me *DB) PostNews(subject string, body string, tags []string) error
- func (me *DB) SetToken(token charm.Token) error
- func (me *DB) SetUserName(charmID string, name string) (*charm.User, error)
- func (me *DB) UnlinkUserKey(user *charm.User, key string) error
- func (me *DB) UserCount() (int, error)
- func (me *DB) UserForKey(key string, create bool) (*charm.User, error)
- func (me *DB) UserNameCount() (int, error)
- func (me *DB) WrapTransaction(f func(tx *sql.Tx) error) error
Constants ¶
const ( // The DB default file name. DbName = "charm_sqlite.db" // The DB default connection options. DbOptions = "?_pragma=busy_timeout(5000)&_pragma=foreign_keys(1)" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is the database struct.
func (*DB) AddEncryptKeyForPublicKey ¶
func (me *DB) AddEncryptKeyForPublicKey(u *charm.User, pk string, gid string, ek string, ca *time.Time) error
AddEncryptKeyForPublicKey adds an ecrypted key to the user.
func (*DB) DeleteToken ¶ added in v0.10.0
DeleteToken deletes the given token.
func (*DB) EncryptKeysForPublicKey ¶
EncryptKeysForPublicKey returns the encrypt keys for the given user.
func (*DB) GetNewsList ¶
GetNewsList returns the list of server news.
func (*DB) GetUserWithID ¶
GetUserWithID returns the user for the given id.
func (*DB) GetUserWithName ¶
GetUserWithName returns the user for the given name.
func (*DB) KeysForUser ¶
KeysForUser returns all user's public keys.
func (*DB) LinkUserKey ¶
LinkUserKey links a user to a key.
func (*DB) MergeUsers ¶
MergeUsers merge two users into a single one.
func (*DB) SetUserName ¶
SetUserName sets a user name for the given user id.
func (*DB) UnlinkUserKey ¶
UnlinkUserKey unlinks the key from the user.
func (*DB) UserForKey ¶
UserForKey returns the user for the given key, or optionally creates a new user with it.
func (*DB) UserNameCount ¶
UserNameCount returns the number of users with a user name set.