spanner

package
v0.0.0-...-0494513 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAppScore

func AddAppScore(ctx context.Context, db ReadWriter, score int64, appIDs ...string) error

func ArgsToParams

func ArgsToParams(args []interface{}) map[string]interface{}

func Delete

func Delete[T tables.Table, K Keys](db BufferWriter, keys ...K) error

func DeleteAppPermissions

func DeleteAppPermissions(ctx context.Context, db DBWriter, appID string, permissionIDs ...string) error

func DeleteAppPermissionsInCircle

func DeleteAppPermissionsInCircle(
	_ context.Context,
	db BufferWriter,
	appID, circleID string,
	permissionIDs ...string,
) error

func DeleteAppReviewVote

func DeleteAppReviewVote(_ context.Context, db BufferWriter, reviewID, userID string) error

func DeleteAppReviews

func DeleteAppReviews(ctx context.Context, db Updater, userID string, reviewIDs ...string) error

func DeleteAppSaves

func DeleteAppSaves(ctx context.Context, db DBWriter, appID, userID string) (err error)

func DeleteAppSubscriptions

func DeleteAppSubscriptions(ctx context.Context, db DBWriter, appID string, subIDs ...string) error

func DeleteAppSubscriptionsInCircle

func DeleteAppSubscriptionsInCircle(
	_ context.Context,
	db BufferWriter,
	appID, circleID string,
	subscriptionIDs ...string,
) error

func DeleteAppTags

func DeleteAppTags(_ context.Context, db BufferWriter, appID string, tagIDs ...string) error

func DeleteAppToken

func DeleteAppToken(
	_ context.Context,
	db BufferWriter,
	tokenID string,
) error

func DeleteAppVote

func DeleteAppVote(_ context.Context, db BufferWriter, appID, userID string) (err error)

func DeleteApps

func DeleteApps(ctx context.Context, db Updater, userID string, appIDs ...string) error

func DeleteByBuilder

func DeleteByBuilder(ctx context.Context, db Updater, b squirrel.DeleteBuilder) (int64, error)

func DeleteCircleApps

func DeleteCircleApps(ctx context.Context, db DBWriter, appID, circleID string) (err error)

func DeleteDefaultApps

func DeleteDefaultApps(_ context.Context, db BufferWriter, appIDs ...string) error

func DeleteFeaturedApps

func DeleteFeaturedApps(_ context.Context, db BufferWriter, appIDs ...string) error

func ExistsAppPermission

func ExistsAppPermission(ctx context.Context, db RowReader, appID, permissionID string) (bool, error)

func ExistsAppReviewVote

func ExistsAppReviewVote(ctx context.Context, db RowReader, reviewID, userID string) (bool, error)

func ExistsAppSave

func ExistsAppSave(ctx context.Context, db RowReader, appID, userID string) (bool, error)

func ExistsAppSubscription

func ExistsAppSubscription(ctx context.Context, db RowReader, appID, subscriptionID string) (bool, error)

func ExistsAppVote

func ExistsAppVote(ctx context.Context, db RowReader, appID, userID string) (bool, error)

func ExistsCircleApp

func ExistsCircleApp(ctx context.Context, db RowReader, appID, circleID string) (bool, error)

func ExistsDefaultApp

func ExistsDefaultApp(ctx context.Context, db RowReader, id string) (bool, error)

func ExistsFeaturedApp

func ExistsFeaturedApp(ctx context.Context, db RowReader, id string) (bool, error)

func ExistsKey

func ExistsKey[T tables.Table, K Key](ctx context.Context, db RowReader, k K) (bool, error)

func GetApp

func GetApp(ctx context.Context, db RowReader, id string) (repo.App, error)

func GetAppCircleCounter

func GetAppCircleCounter(ctx context.Context, db RowReader, id string) (repo.AppCounters, error)

func GetAppLastUsedByUser

func GetAppLastUsedByUser(ctx context.Context, db Reader, appID, userID string) (*time.Time, error)

func GetAppPermissions

func GetAppPermissions(ctx context.Context, db Reader, appID string) ([]string, error)

func GetAppPermissionsInCircle

func GetAppPermissionsInCircle(ctx context.Context, db Queryer, appID, circleID string) ([]string, error)

func GetAppReviewVote

func GetAppReviewVote(ctx context.Context, db RowReader, reviewID, userID string) (*repo.AppReviewVote, error)

func GetAppReviews

func GetAppReviews(ctx context.Context, db Reader, ids ...string) ([]repo.AppReview, error)

func GetAppReviewsByAppID

func GetAppReviewsByAppID(ctx context.Context, db Queryer, appID string, c cursor.Cursor) ([]repo.AppReview, error)

func GetAppReviewsByUserID

func GetAppReviewsByUserID(ctx context.Context, db Queryer, appID, userID string) ([]repo.AppReview, error)

func GetAppRoles

func GetAppRoles(ctx context.Context, db Reader, appID string) ([]string, error)

func GetAppSavedByUser

func GetAppSavedByUser(ctx context.Context, db Reader, appID, userID string) (*time.Time, error)

func GetAppSubscriptions

func GetAppSubscriptions(ctx context.Context, db Reader, appID string) ([]string, error)

func GetAppSubscriptionsInCircle

func GetAppSubscriptionsInCircle(ctx context.Context, db Queryer, appID, circleID string) ([]string, error)

func GetAppTags

func GetAppTags(ctx context.Context, db Queryer, appID string) ([]repo.Tag, error)

func GetAppToken

func GetAppToken(ctx context.Context, db RowReader, tokenID string) (repo.AppToken, bool, error)

func GetAppTokens

func GetAppTokens(ctx context.Context, db Queryer, appID string) ([]repo.AppToken, error)

func GetAppUpvotedByUser

func GetAppUpvotedByUser(ctx context.Context, db Reader, appID, userID string) (*time.Time, error)

func GetApps

func GetApps(ctx context.Context, db Reader, ids ...string) ([]repo.App, error)

func GetAppsBySearch

func GetAppsBySearch(ctx context.Context, db Queryer, f repo.SearchAppsFilter) ([]repo.App, error)

func GetAppsCreatedBy

func GetAppsCreatedBy(ctx context.Context, db Queryer, createdBy string) ([]repo.App, error)

func GetAppsPermissions

func GetAppsPermissions(ctx context.Context, db Reader, appIDs ...string) (map[string][]string, error)

func GetAppsSubscriptions

func GetAppsSubscriptions(ctx context.Context, db Reader, appIDs ...string) (map[string][]string, error)

func GetByKey

func GetByKey[M any, T tables.Table, K Key](ctx context.Context, db RowReader, k K) (m M, err error)

func GetByKeys

func GetByKeys[M any, T tables.Table, K Keys](ctx context.Context, db Reader, ids ...K) ([]M, error)

func GetCircleApps

func GetCircleApps(ctx context.Context, db Queryer, filter repo.CircleAppsFilter) ([]repo.CircleApp, error)

func GetCircleSubscribers

func GetCircleSubscribers(ctx context.Context, db Reader, circleID, subscriptionID string) ([]string, error)

func GetCircles

func GetCircles(ctx context.Context, db Reader, ids ...string) ([]repo.Circle, error)

func GetDefaultApps

func GetDefaultApps(ctx context.Context, db Reader) ([]string, error)

func GetFeaturedApps

func GetFeaturedApps(ctx context.Context, db Reader) ([]string, error)

func GetLastUsedApps

func GetLastUsedApps(ctx context.Context, db Queryer, userID string, c cursor.Cursor) ([]string, error)

func GetPermissions

func GetPermissions(ctx context.Context, db Reader, ids ...string) ([]repo.Permission, error)

func GetPtrResults

func GetPtrResults[M any](iter *spanner.RowIterator) (out []*M, err error)

GetPtrResults returns the results from the iterator. Calls Stop after the iterator is finished.

func GetResult

func GetResult[M any](iter *spanner.RowIterator) (out M, err error)

GetResult returns the result from the iterator. Calls Stop after the iterator is finished.

func GetResultByBuilder

func GetResultByBuilder[M any](ctx context.Context, db Queryer, b squirrel.SelectBuilder) (m M, err error)

func GetResults

func GetResults[M any](iter *spanner.RowIterator) (out []M, err error)

GetResults returns the results from the iterator. Calls Stop after the iterator is finished.

func GetResultsByBuilder

func GetResultsByBuilder[M any](ctx context.Context, db Queryer, b squirrel.SelectBuilder) ([]M, error)

func GetSavedApps

func GetSavedApps(ctx context.Context, db Queryer, userID string, f repo.GetSavedAppsFilter) ([]repo.AppSave, error)

func GetSubscriptions

func GetSubscriptions(ctx context.Context, db Reader, ids ...string) ([]repo.Subscription, error)

func GetTags

func GetTags(ctx context.Context, db Reader, ids ...string) ([]repo.Tag, error)

func IncAppCircleCounter

func IncAppCircleCounter(ctx context.Context, db ReadWriter, value int64, appIDs ...string) error

func IncAppRatingCounter

func IncAppRatingCounter(ctx context.Context, db ReadWriter, rating, count int64, appIDs ...string) error

func IncAppReviewDownvote

func IncAppReviewDownvote(ctx context.Context, db Updater, value int64, reviewID string) error

func IncAppReviewUpvote

func IncAppReviewUpvote(ctx context.Context, db Updater, value int64, reviewID string) error

func IncAppSaveCounter

func IncAppSaveCounter(ctx context.Context, db ReadWriter, value int64, appIDs ...string) error

func IncAppVoteCounter

func IncAppVoteCounter(ctx context.Context, db ReadWriter, value int64, appIDs ...string) error

func InsertApp

func InsertApp(_ context.Context, db BufferWriter, in repo.AppCreateInput) error

func InsertAppReviewVote

func InsertAppReviewVote(_ context.Context, db BufferWriter, reviewID, userID string, isUpvote bool) error

func InsertAppRole

func InsertAppRole(_ context.Context, db BufferWriter, appID, roleID string) error

func InsertAppSaves

func InsertAppSaves(_ context.Context, db BufferWriter, in ...repo.AddAppSaveInput) error

func InsertAppToken

func InsertAppToken(_ context.Context, db BufferWriter, appTokenInput repo.InsertAppTokenInput) error

func InsertAppVote

func InsertAppVote(_ context.Context, db BufferWriter, appID, userID string) error

func InsertByBuilder

func InsertByBuilder(ctx context.Context, db Updater, b squirrel.InsertBuilder) (int64, error)

func InsertCircleApps

func InsertCircleApps(_ context.Context, db BufferWriter, in ...repo.AddCircleAppInput) error

func InsertDefaultApps

func InsertDefaultApps(_ context.Context, db BufferWriter, userID string, appIDs ...string) error

func InsertFeaturedApps

func InsertFeaturedApps(_ context.Context, db BufferWriter, userID string, appIDs ...string) error

func NewSpannerClient

func NewSpannerClient(ctx context.Context, dsn, adcCredPath string) (*spanner.Client, error)

func UpdateApp

func UpdateApp(_ context.Context, db BufferWriter, appID, userID string, in repo.AppUpdateInput) error

func UpdateByBuilder

func UpdateByBuilder(ctx context.Context, db Updater, b squirrel.UpdateBuilder) (int64, error)

func UpdateCircle

func UpdateCircle(_ context.Context, db BufferWriter, circleID string, in repo.CircleUpdateInput) error

func UpsertAppPermissionInCircles

func UpsertAppPermissionInCircles(_ context.Context, db BufferWriter, perms ...repo.AppPermissionInCircle) error

func UpsertAppPermissions

func UpsertAppPermissions(_ context.Context, db BufferWriter, appID string, permissionIDs ...string) error

func UpsertAppReviewVote

func UpsertAppReviewVote(_ context.Context, db BufferWriter, reviewID, userID string, isUpvote bool) error

func UpsertAppSubscriptionInCircles

func UpsertAppSubscriptionInCircles(_ context.Context, db BufferWriter, in ...repo.AppSubscriptionInCircle) error

func UpsertAppSubscriptions

func UpsertAppSubscriptions(_ context.Context, db BufferWriter, appID string, subscriptionIDs ...string) error

func UpsertAppTags

func UpsertAppTags(_ context.Context, db BufferWriter, appID string, tagIDs ...string) error

func UpsertCircles

func UpsertCircles(_ context.Context, db BufferWriter, in ...repo.CircleCreateInput) error

func UpsertLastUsedApp

func UpsertLastUsedApp(_ context.Context, db BufferWriter, appID, userID string) error

func UpsertPermissions

func UpsertPermissions(_ context.Context, db BufferWriter, permissions ...repo.Permission) error

func UpsertSubscriptions

func UpsertSubscriptions(_ context.Context, db BufferWriter, subs ...repo.Subscription) error

func UpsertTags

func UpsertTags(_ context.Context, db BufferWriter, tags ...repo.Tag) error

Types

type BufferWriter

type BufferWriter interface {
	BufferWrite([]*spanner.Mutation) error
}

type DBWriter

type DBWriter interface {
	Updater
	BufferWriter
}

type IndexReader

type IndexReader interface {
	ReadUsingIndex(ctx context.Context, table, index string, keys spanner.KeySet, columns []string) *spanner.RowIterator
}

type Key

type Key interface{ string | spanner.Key }

type Keys

type Keys interface{ Key | spanner.KeyRange }

type Queryer

type Queryer interface {
	Query(context.Context, spanner.Statement) *spanner.RowIterator
}

type ReadWriter

type ReadWriter interface {
	Reader
	BufferWriter
}

type Reader

type Reader interface {
	Read(ctx context.Context, table string, k spanner.KeySet, cols []string) *spanner.RowIterator
}

type Repo

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

func NewRepoWithClient

func NewRepoWithClient(cli *spanner.Client) Repo

func (Repo) Close

func (r Repo) Close()

func (Repo) ReadOnlyTx

func (r Repo) ReadOnlyTx(ctx context.Context, f func(context.Context, repo.ReadActions) error) error

func (Repo) ReadWriteTx

func (r Repo) ReadWriteTx(
	ctx context.Context,
	f func(context.Context, repo.ReadWriteActions) error,
) (time.Time, error)

func (Repo) SingleRead

func (r Repo) SingleRead() repo.ReadActions

func (Repo) SingleWrite

func (r Repo) SingleWrite() repo.WriteActions

type RowReader

type RowReader interface {
	ReadRow(ctx context.Context, table string, k spanner.Key, cols []string) (*spanner.Row, error)
}

type Updater

type Updater interface {
	Update(context.Context, spanner.Statement) (int64, error)
}

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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