database

package
v0.6.2-0...-436338d Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StormCodec = storm.Codec(msgpack.Codec)

StormCodec is the format used to store data in the database.

Functions

func StormInit

func StormInit(database string) error

StormInit initializes Storm database.

func StormReIndex

func StormReIndex(database string) error

StormReIndex reindex Storm database.

Types

type Client

type Client interface {
	// Save inserts or updates the entry in database with the given model.
	Save(m model.Model) error
	// Delete deletes the entry in database with the given model.
	Delete(m model.Model) error
	// Close the database.
	Close() error
	// IsNotFound returns true if err is nil or a not found error.
	IsNotFound(err error) bool

	UserInteraction
	SessionInteraction
	ItemInteraction
}

A Client can interacts with the database.

func StormOpen

func StormOpen(database string) (Client, error)

StormOpen returns a new Storm database connection.

type ItemInteraction

type ItemInteraction interface {
	// FindItem returns the item for the given id (UUID).
	FindItem(id string) (*model.Item, error)
	// FindItemByUserID returns the item for the given id and user id (UUID).
	FindItemByUserID(id, userID string) (*model.Item, error)
	// FindItemsByParams returns all the matching records for the given parameters.
	// It also returns a boolean to true if there is more items than the given limit.
	// limit equals to 0 means all items.
	FindItemsByParams(userID, contentType string, updated time.Time, strictTime, filterDeleted bool, limit int) ([]*model.Item, bool, error)
	// FindItemsForIntegrityCheck returns valid items for computing data signature forthe given user.
	FindItemsForIntegrityCheck(userID string) ([]*model.Item, error)
	// DeleteItem deletes the item matching the given parameters.
	DeleteItem(id, userID string) error
}

An ItemInteraction defines all the methods used to interact with a item record(s).

type SessionInteraction

type SessionInteraction interface {
	// FindSession returns the session for the given id (UUID).
	FindSession(id string) (*model.Session, error)
	// FindSessionsByUserID returns all sessions for the given id and user id.
	FindSessionByUserID(id, userID string) (*model.Session, error)
	// FindActiveSessionsByUserID returns all active sessions for the given user id.
	FindActiveSessionsByUserID(userID string) ([]*model.Session, error)
	// FindSessionsByUserID returns all sessions for the given user id.
	FindSessionsByUserID(userID string) ([]*model.Session, error)
	// FindSessionByAccessToken returns the session for the given id and access token.
	FindSessionByAccessToken(id, token string) (*model.Session, error)
	// FindSessionByTokens returns the session for the given id, access and refresh token.
	FindSessionByTokens(id, access, refresh string) (*model.Session, error)
}

An SessionInteraction defines all the methods used to interact with a session record.

type UserInteraction

type UserInteraction interface {
	// FindUser returns the user for the given id (UUID).
	FindUser(id string) (*model.User, error)
	// FindUserByMail returns the user for the given email.
	FindUserByMail(email string) (*model.User, error)
}

An UserInteraction defines all the methods used to interact with a user record.

Jump to

Keyboard shortcuts

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