postgres

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package postgres provides a postgresql-backed implementation of the user.Store interface

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

func NewPostgresStore

func NewPostgresStore(db *gorm.DB) *Store

NewPostgresStore creates a new postgres store

func (*Store) Add

func (s *Store) Add(ctx context.Context, u *user.User) error

Add upserts a user to the postgres store

func (*Store) Find

func (s *Store) Find(ctx context.Context, possibleIdentifiers identifier.Set) (*user.User, error)

Find implements user.Store.

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string) (*user.User, error)

Get implements user.Store.

func (*Store) GetByIdentifier

func (s *Store) GetByIdentifier(ctx context.Context, id identifier.Identifier) (*user.User, error)

GetByIdentifier implements user.Store.

func (*Store) SetPreferences

func (s *Store) SetPreferences(ctx context.Context, key string, prefs preference.Map) error

SetPreferences implements user.Store.

type UserModel

type UserModel struct {
	Key         string         `gorm:"primarykey"`
	Preferences preference.Map `gorm:"serializer:json"`

	// Identifiers is a map of all identifiers for the user
	Identifiers map[identifier.NamespaceAndKind]string `gorm:"serializer:json"`
	// Emails contains the subset of Identifiers that have Kind=="email" (for easier fallback lookup)
	Emails []string `gorm:"serializer:json"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

UserModel is the gorm model for a user

func (*UserModel) TableName

func (u *UserModel) TableName() string

func (*UserModel) ToUser

func (u *UserModel) ToUser() *user.User

ToUser converts a UserModel to a user.User

Jump to

Keyboard shortcuts

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