storage

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSystemStorage

type FileSystemStorage struct {
	Directory      string
	ID2Filename    map[ulid.ULID]string
	Email2Filename map[string]string
}

Stores data in a flat directory with files named like $<userid>$<email>.json

func NewFileSystemStorage

func NewFileSystemStorage(dir string) (result *FileSystemStorage, err error)

func (*FileSystemStorage) GetUserByEmail

func (fss *FileSystemStorage) GetUserByEmail(email string) (user *gomagiclink.AuthUserRecord, err error)

func (*FileSystemStorage) GetUserById

func (fss *FileSystemStorage) GetUserById(id ulid.ULID) (user *gomagiclink.AuthUserRecord, err error)

func (*FileSystemStorage) GetUserCount added in v0.9.3

func (fss *FileSystemStorage) GetUserCount() (int, error)

func (*FileSystemStorage) StoreUser

func (fss *FileSystemStorage) StoreUser(user *gomagiclink.AuthUserRecord) (err error)

func (*FileSystemStorage) UserExistsByEmail

func (fss *FileSystemStorage) UserExistsByEmail(email string) (exists bool)

func (*FileSystemStorage) UsersExist added in v0.9.4

func (fss *FileSystemStorage) UsersExist() (bool, error)

type SQLStorage

type SQLStorage struct {
	// contains filtered or unexported fields
}

func NewSQLStorage

func NewSQLStorage(db *sql.DB, tableName string) (st *SQLStorage, err error)

NewSQLStorate creates a SQLStorage instance. This storage engine will use a single table in the SQL database, that needs to have these fields:

id		Some type that can store the 16-byte ULID, either as a text field (26 characters), or a dedicated type (PostgreSQL has a plugin for the native ULID type)
email	text
data	A type that can accept a long JSON string, either as text, or as a dedicated type (PostgreSQL has a native JSONB field)

This table needs to be maintained entirely by the caller, including indexes. A unique index on the `id` field, and another unique index on the `email` field are highly recommended.

func (*SQLStorage) GetUserByEmail

func (st *SQLStorage) GetUserByEmail(email string) (user *gomagiclink.AuthUserRecord, err error)

func (*SQLStorage) GetUserById

func (st *SQLStorage) GetUserById(id ulid.ULID) (user *gomagiclink.AuthUserRecord, err error)

func (*SQLStorage) GetUserCount added in v0.9.3

func (st *SQLStorage) GetUserCount() (n int, err error)

func (*SQLStorage) StoreUser

func (st *SQLStorage) StoreUser(user *gomagiclink.AuthUserRecord) (err error)

func (*SQLStorage) UserExistsByEmail

func (st *SQLStorage) UserExistsByEmail(email string) (exists bool)

func (*SQLStorage) UsersExist added in v0.9.4

func (st *SQLStorage) UsersExist() (exist bool, err error)

Jump to

Keyboard shortcuts

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