stores

package
v0.0.0-...-45a0741 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProgressStore

type ProgressStore interface {
	GetProgress(userId bson.ObjectId) (*progress.Progress, error)
	SetProgress(userId bson.ObjectId, progress progress.Progress) error
	CreateProgress(userId bson.ObjectId) (*progress.Progress, error)
}

type SessionsStore

type SessionsStore interface {
	GetSession(token string) (*models.Session, error)
	CreateSession(userID bson.ObjectId, token string) error
	DeleteSessions(userID bson.ObjectId) error
}

type SettingsStore

type SettingsStore interface {
	GetUserSettings(userID bson.ObjectId) (*models.Settings, error)
	CreateUserSettings(userID bson.ObjectId) error
	UpdateUserSettings(userID bson.ObjectId, settings *models.Settings) error
}

type Store

type Store struct {
	Users    *mgo.Collection
	Sessions *mgo.Collection
	Settings *mgo.Collection
	Progress *mgo.Collection
	// contains filtered or unexported fields
}

func InitStore

func InitStore(connStr string) *Store

func (*Store) CreateProgress

func (s *Store) CreateProgress(userId bson.ObjectId) (*progress.Progress, error)

func (*Store) CreateSession

func (s *Store) CreateSession(userID bson.ObjectId, token string) error

func (*Store) CreateUser

func (s *Store) CreateUser(user *models.User) error

CreateUser store a user in a db

func (*Store) CreateUserByAddress

func (s *Store) CreateUserByAddress(address string, user *models.User) error

CreateUserByAddress creates a user by address if not exists

func (*Store) CreateUserSettings

func (s *Store) CreateUserSettings(userID bson.ObjectId) error

func (*Store) DeleteSessions

func (s *Store) DeleteSessions(userID bson.ObjectId) error

func (*Store) GetProgress

func (s *Store) GetProgress(userId bson.ObjectId) (*progress.Progress, error)

func (*Store) GetSession

func (s *Store) GetSession(token string) (*models.Session, error)

func (*Store) GetUser

func (s *Store) GetUser(id bson.ObjectId) (*models.User, error)

User returns a user by id

func (*Store) GetUserSettings

func (s *Store) GetUserSettings(userID bson.ObjectId) (*models.Settings, error)

func (*Store) ListUsers

func (s *Store) ListUsers() (*[]models.User, error)

Users returns a list of users

func (*Store) SetProgress

func (s *Store) SetProgress(userId bson.ObjectId, p progress.Progress) error

func (*Store) ShutDownStore

func (store *Store) ShutDownStore()

func (*Store) UpdateUserSettings

func (s *Store) UpdateUserSettings(userID bson.ObjectId, settings *models.Settings) error

func (*Store) UserByPublicKey

func (s *Store) UserByPublicKey(pubkey string) (*models.User, error)

UserByPublicKey returns a user by public key hex string

type UsersStore

type UsersStore interface {
	GetUser(id bson.ObjectId) (*models.User, error)
	ListUsers() (*[]models.User, error)
	UserByPublicKey(pubkey string) (*models.User, error)
	CreateUser(user *models.User) error
	CreateUserByAddress(address string, user *models.User) error
}

Jump to

Keyboard shortcuts

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