sqlite

package
v0.12.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2023 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
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 NewDB

func NewDB(path string) *DB

NewDB creates a new DB in the given path.

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) Close added in v0.11.0

func (me *DB) Close() error

Close the db.

func (*DB) CreateDB

func (me *DB) CreateDB() error

CreateDB creates the database.

func (*DB) DeleteToken added in v0.10.0

func (me *DB) DeleteToken(token charm.Token) error

DeleteToken deletes the given token.

func (*DB) EncryptKeysForPublicKey

func (me *DB) EncryptKeysForPublicKey(pk *charm.PublicKey) ([]*charm.EncryptKey, error)

EncryptKeysForPublicKey returns the encrypt keys for the given user.

func (*DB) GetNews

func (me *DB) GetNews(id string) (*charm.News, error)

GetNews returns the server news.

func (*DB) GetNewsList

func (me *DB) GetNewsList(tag string, page int) ([]*charm.News, error)

GetNewsList returns the list of server news.

func (*DB) GetSeq

func (me *DB) GetSeq(u *charm.User, name string) (uint64, error)

GetSeq returns the named sequence.

func (*DB) GetUserWithID

func (me *DB) GetUserWithID(charmID string) (*charm.User, error)

GetUserWithID returns the user for the given id.

func (*DB) GetUserWithName

func (me *DB) GetUserWithName(name string) (*charm.User, error)

GetUserWithName returns the user for the given name.

func (*DB) KeysForUser

func (me *DB) KeysForUser(user *charm.User) ([]*charm.PublicKey, error)

KeysForUser returns all user's public keys.

func (*DB) LinkUserKey

func (me *DB) LinkUserKey(user *charm.User, key string) error

LinkUserKey links a user to a key.

func (*DB) MergeUsers

func (me *DB) MergeUsers(userID1 int, userID2 int) error

MergeUsers merge two users into a single one.

func (*DB) NextSeq

func (me *DB) NextSeq(u *charm.User, name string) (uint64, error)

NextSeq increments the sequence and returns.

func (*DB) PostNews

func (me *DB) PostNews(subject string, body string, tags []string) error

PostNews publish news to the server.

func (*DB) SetToken added in v0.10.0

func (me *DB) SetToken(token charm.Token) error

SetToken creates the given token.

func (*DB) SetUserName

func (me *DB) SetUserName(charmID string, name string) (*charm.User, error)

SetUserName sets a user name for the given user id.

func (*DB) UnlinkUserKey

func (me *DB) UnlinkUserKey(user *charm.User, key string) error

UnlinkUserKey unlinks the key from the user.

func (*DB) UserCount

func (me *DB) UserCount() (int, error)

UserCount returns the number of users.

func (*DB) UserForKey

func (me *DB) UserForKey(key string, create bool) (*charm.User, error)

UserForKey returns the user for the given key, or optionally creates a new user with it.

func (*DB) UserNameCount

func (me *DB) UserNameCount() (int, error)

UserNameCount returns the number of users with a user name set.

func (*DB) WrapTransaction added in v0.10.3

func (me *DB) WrapTransaction(f func(tx *sql.Tx) error) error

WrapTransaction runs the given function within a transaction.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL