db

package
v0.0.0-...-64f428f Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

func GetContinuationToken

func GetContinuationToken(apiUrl, storeId string) *string

func GetObjectTypes

func GetObjectTypes() []string

func GetRelations

func GetRelations() []string

func GetUserTypes

func GetUserTypes() []string

func MarkDeletion

func MarkDeletion(tupleKey string)

func MarkStale

func MarkStale(tupleKey string)

func SetupDb

func SetupDb()

func Transact

func Transact(f func()) error

Transact keeps it simple and executes the passed function

func UpsertConnection

func UpsertConnection(connection Connection)

Types

type Connection

type Connection struct {
	ApiUrl            string    `db:"api_url"`
	StoreId           string    `db:"store_id"`
	ContinuationToken string    `db:"continuation_token"`
	LastSync          time.Time `db:"last_sync"`
}

type Filter

type Filter struct {
	Search     *string
	UserType   *string
	Relation   *string
	ObjectType *string
}

type LoadResult

type LoadResult struct {

	// the tuple content itself
	Res []TuplePendingAction
	// whatever was the filter user, it's returned
	Filter *Filter
	// contains filtered or unexported fields
}

LoadResult represents the last page load

func Load

func Load(offset int, filter *Filter) *LoadResult

func (*LoadResult) GetLowerBound

func (l *LoadResult) GetLowerBound() int

func (*LoadResult) GetTotal

func (l *LoadResult) GetTotal() int

func (*LoadResult) GetUpperBound

func (l *LoadResult) GetUpperBound() int

type PendingAction

type PendingAction struct {
	Action string `db:"action"`
}

type SqlxRepository

type SqlxRepository struct {
	TupleRepository
	// contains filtered or unexported fields
}

func (*SqlxRepository) ApplyChange

func (r *SqlxRepository) ApplyChange(change openfga.TupleChange)

func (*SqlxRepository) CountTuples

func (r *SqlxRepository) CountTuples(filter *Filter) int

func (*SqlxRepository) GetMarkedForDeletion

func (r *SqlxRepository) GetMarkedForDeletion() []Tuple

func (*SqlxRepository) Prune

func (r *SqlxRepository) Prune() int

type Tuple

type Tuple struct {
	TupleKey   string    `db:"tuple_key"`
	UserType   string    `db:"user_type"`
	UserId     string    `db:"user_id"`
	Relation   string    `db:"relation"`
	ObjectType string    `db:"object_type"`
	ObjectId   string    `db:"object_id"`
	Timestamp  time.Time `db:"timestamp"`
	Row        int       `db:"row_number"`
}

type TuplePendingAction

type TuplePendingAction struct {
	*Tuple
	*PendingAction
}

type TupleRepository

type TupleRepository interface {
	CountTuples(filter *Filter) int
	GetMarkedForDeletion() []Tuple
	ApplyChange(change openfga.TupleChange)
	Prune() int
}
var (
	Repository TupleRepository
)

Jump to

Keyboard shortcuts

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