2024-02-27 14:14:30 +01:00
|
|
|
package datastore
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
|
|
|
type TenantRepository interface {
|
|
|
|
Create(ctx context.Context, label string) (*Tenant, error)
|
|
|
|
Get(ctx context.Context, id TenantID) (*Tenant, error)
|
|
|
|
Update(ctx context.Context, id TenantID, updates ...TenantUpdateOptionFunc) (*Tenant, error)
|
|
|
|
Delete(ctx context.Context, id TenantID) error
|
2024-02-27 17:01:24 +01:00
|
|
|
|
|
|
|
Query(ctx context.Context, opts ...TenantQueryOptionFunc) ([]*Tenant, int, error)
|
2024-02-27 14:14:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type TenantUpdateOptionFunc func(*TenantUpdateOptions)
|
|
|
|
|
|
|
|
type TenantUpdateOptions struct {
|
|
|
|
Label *string
|
|
|
|
}
|
|
|
|
|
|
|
|
func WithTenantUpdateLabel(label string) TenantUpdateOptionFunc {
|
|
|
|
return func(opts *TenantUpdateOptions) {
|
|
|
|
opts.Label = &label
|
|
|
|
}
|
|
|
|
}
|
2024-02-27 17:01:24 +01:00
|
|
|
|
|
|
|
type TenantQueryOptionFunc func(*TenantQueryOptions)
|
|
|
|
|
|
|
|
type TenantQueryOptions struct {
|
|
|
|
Limit *int
|
|
|
|
Offset *int
|
|
|
|
IDs []TenantID
|
|
|
|
}
|
|
|
|
|
|
|
|
func WithTenantQueryLimit(limit int) TenantQueryOptionFunc {
|
|
|
|
return func(opts *TenantQueryOptions) {
|
|
|
|
opts.Limit = &limit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func WithTenantQueryOffset(offset int) TenantQueryOptionFunc {
|
|
|
|
return func(opts *TenantQueryOptions) {
|
|
|
|
opts.Offset = &offset
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func WithTenantQueryID(ids ...TenantID) TenantQueryOptionFunc {
|
|
|
|
return func(opts *TenantQueryOptions) {
|
|
|
|
opts.IDs = ids
|
|
|
|
}
|
|
|
|
}
|