Documentation ¶
Index ¶
- Constants
- func IsObjectSortBy(sortBy string) bool
- type CreateObjectSpec
- type FilterOptions
- type ListObjectSpecV1
- type ListObjectsSpecV2
- type Model
- type MySQLRepository
- func (repo MySQLRepository) BatchGetByObjectTypeAndIds(ctx context.Context, objectType string, objectIds []string) ([]Model, error)
- func (repo MySQLRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo MySQLRepository) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error
- func (repo MySQLRepository) DeleteWarrantsMatchingObject(ctx context.Context, objectType string, objectId string) error
- func (repo MySQLRepository) DeleteWarrantsMatchingSubject(ctx context.Context, subjectType string, subjectId string) error
- func (repo MySQLRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo MySQLRepository) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (Model, error)
- func (repo MySQLRepository) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]Model, *service.Cursor, *service.Cursor, error)
- func (repo MySQLRepository) UpdateByObjectTypeAndId(ctx context.Context, objectType string, objectId string, model Model) error
- type Object
- func (object Object) GetCreatedAt() time.Time
- func (object Object) GetDeletedAt() *time.Time
- func (object Object) GetID() int64
- func (object Object) GetMeta() *string
- func (object Object) GetObjectId() string
- func (object Object) GetObjectType() string
- func (object Object) GetUpdatedAt() time.Time
- func (object *Object) SetMeta(newMeta map[string]interface{}) error
- func (object Object) ToObjectSpec() (*ObjectSpec, error)
- type ObjectListParamParser
- type ObjectRepository
- type ObjectService
- func (svc ObjectService) BatchGetByObjectTypeAndIds(ctx context.Context, objectType string, objectIds []string) ([]ObjectSpec, error)
- func (svc ObjectService) Create(ctx context.Context, objectSpec CreateObjectSpec) (*ObjectSpec, error)
- func (svc ObjectService) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (*wookie.Token, error)
- func (svc ObjectService) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (*ObjectSpec, error)
- func (svc ObjectService) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]ObjectSpec, *service.Cursor, *service.Cursor, error)
- func (svc ObjectService) Routes() ([]service.Route, error)
- func (svc ObjectService) UpdateByObjectTypeAndId(ctx context.Context, objectType string, objectId string, ...) (*ObjectSpec, error)
- type ObjectSpec
- type PostgresRepository
- func (repo PostgresRepository) BatchGetByObjectTypeAndIds(ctx context.Context, objectType string, objectIds []string) ([]Model, error)
- func (repo PostgresRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo PostgresRepository) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error
- func (repo PostgresRepository) DeleteWarrantsMatchingObject(ctx context.Context, objectType string, objectId string) error
- func (repo PostgresRepository) DeleteWarrantsMatchingSubject(ctx context.Context, subjectType string, subjectId string) error
- func (repo PostgresRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo PostgresRepository) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (Model, error)
- func (repo PostgresRepository) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]Model, *service.Cursor, *service.Cursor, error)
- func (repo PostgresRepository) UpdateByObjectTypeAndId(ctx context.Context, objectType string, objectId string, model Model) error
- type SQLiteRepository
- func (repo SQLiteRepository) BatchGetByObjectTypeAndIds(ctx context.Context, objectType string, objectIds []string) ([]Model, error)
- func (repo SQLiteRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo SQLiteRepository) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error
- func (repo SQLiteRepository) DeleteWarrantsMatchingObject(ctx context.Context, objectType string, objectId string) error
- func (repo SQLiteRepository) DeleteWarrantsMatchingSubject(ctx context.Context, subjectType string, subjectId string) error
- func (repo SQLiteRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo SQLiteRepository) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (Model, error)
- func (repo SQLiteRepository) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]Model, *service.Cursor, *service.Cursor, error)
- func (repo SQLiteRepository) UpdateByObjectTypeAndId(ctx context.Context, objectType string, objectId string, model Model) error
- type Service
- type UpdateObjectSpec
Constants ¶
View Source
const PrimarySortKey = "objectId"
Variables ¶
This section is empty.
Functions ¶
func IsObjectSortBy ¶
Types ¶
type CreateObjectSpec ¶
type CreateObjectSpec struct { ObjectType string `json:"objectType" validate:"required,valid_object_type"` ObjectId string `json:"objectId" validate:"omitempty,valid_object_id"` Meta map[string]interface{} `json:"meta"` }
func (CreateObjectSpec) ToObject ¶
func (spec CreateObjectSpec) ToObject() (*Object, error)
type FilterOptions ¶
type FilterOptions struct {
ObjectType string `json:"objectType,omitempty"`
}
type ListObjectSpecV1 ¶ added in v0.57.0
type ListObjectSpecV1 []ObjectSpec
type ListObjectsSpecV2 ¶ added in v0.57.0
type ListObjectsSpecV2 struct { Results []ObjectSpec `json:"results"` NextCursor *service.Cursor `json:"nextCursor,omitempty"` PrevCursor *service.Cursor `json:"prevCursor,omitempty"` }
type MySQLRepository ¶
type MySQLRepository struct {
database.SQLRepository
}
func NewMySQLRepository ¶
func NewMySQLRepository(db *database.MySQL) *MySQLRepository
func (MySQLRepository) BatchGetByObjectTypeAndIds ¶
func (MySQLRepository) DeleteByObjectTypeAndId ¶
func (MySQLRepository) DeleteWarrantsMatchingObject ¶
func (MySQLRepository) DeleteWarrantsMatchingSubject ¶
func (MySQLRepository) GetByObjectTypeAndId ¶
func (MySQLRepository) List ¶
func (repo MySQLRepository) List(ctx context.Context, filterOptions *FilterOptions, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)
func (MySQLRepository) UpdateByObjectTypeAndId ¶
type Object ¶
type Object struct { ID int64 `mysql:"id" postgres:"id" sqlite:"id"` ObjectType string `mysql:"objectType" postgres:"object_type" sqlite:"objectType"` ObjectId string `mysql:"objectId" postgres:"object_id" sqlite:"objectId"` Meta *string `mysql:"meta" postgres:"meta" sqlite:"meta"` CreatedAt time.Time `mysql:"createdAt" postgres:"created_at" sqlite:"createdAt"` UpdatedAt time.Time `mysql:"updatedAt" postgres:"updated_at" sqlite:"updatedAt"` DeletedAt *time.Time `mysql:"deletedAt" postgres:"deleted_at" sqlite:"deletedAt"` }
func (Object) GetCreatedAt ¶
func (Object) GetDeletedAt ¶
func (Object) GetObjectId ¶
func (Object) GetObjectType ¶
func (Object) GetUpdatedAt ¶
func (Object) ToObjectSpec ¶
func (object Object) ToObjectSpec() (*ObjectSpec, error)
type ObjectListParamParser ¶
type ObjectListParamParser struct{}
func (ObjectListParamParser) GetDefaultSortBy ¶
func (parser ObjectListParamParser) GetDefaultSortBy() string
func (ObjectListParamParser) GetSupportedSortBys ¶
func (parser ObjectListParamParser) GetSupportedSortBys() []string
func (ObjectListParamParser) ParseValue ¶
func (parser ObjectListParamParser) ParseValue(val string, sortBy string) (interface{}, error)
type ObjectRepository ¶
type ObjectRepository interface { Create(ctx context.Context, object Model) (int64, error) GetById(ctx context.Context, id int64) (Model, error) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (Model, error) BatchGetByObjectTypeAndIds(ctx context.Context, objectType string, objectIds []string) ([]Model, error) List(ctx context.Context, filterOptions *FilterOptions, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error) UpdateByObjectTypeAndId(ctx context.Context, objectType string, objectId string, object Model) error DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error DeleteWarrantsMatchingObject(ctx context.Context, objectType string, objectId string) error DeleteWarrantsMatchingSubject(ctx context.Context, subjectType string, subjectId string) error }
func NewRepository ¶
func NewRepository(db database.Database) (ObjectRepository, error)
type ObjectService ¶
type ObjectService struct { service.BaseService // contains filtered or unexported fields }
func NewService ¶
func NewService(env service.Env, repository ObjectRepository) *ObjectService
func (ObjectService) BatchGetByObjectTypeAndIds ¶
func (svc ObjectService) BatchGetByObjectTypeAndIds(ctx context.Context, objectType string, objectIds []string) ([]ObjectSpec, error)
func (ObjectService) Create ¶
func (svc ObjectService) Create(ctx context.Context, objectSpec CreateObjectSpec) (*ObjectSpec, error)
func (ObjectService) DeleteByObjectTypeAndId ¶
func (ObjectService) GetByObjectTypeAndId ¶
func (svc ObjectService) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (*ObjectSpec, error)
func (ObjectService) List ¶
func (svc ObjectService) List(ctx context.Context, filterOptions *FilterOptions, listParams service.ListParams) ([]ObjectSpec, *service.Cursor, *service.Cursor, error)
func (ObjectService) UpdateByObjectTypeAndId ¶
func (svc ObjectService) UpdateByObjectTypeAndId(ctx context.Context, objectType string, objectId string, updateSpec UpdateObjectSpec) (*ObjectSpec, error)
type ObjectSpec ¶
type ObjectSpec struct { // NOTE: ID is required here for internal use. // However, we don't return it to the client. ID int64 `json:"-"` ObjectType string `json:"objectType"` ObjectId string `json:"objectId"` Meta map[string]interface{} `json:"meta,omitempty"` CreatedAt time.Time `json:"createdAt"` }
type PostgresRepository ¶
type PostgresRepository struct {
database.SQLRepository
}
func NewPostgresRepository ¶
func NewPostgresRepository(db *database.Postgres) *PostgresRepository
func (PostgresRepository) BatchGetByObjectTypeAndIds ¶
func (PostgresRepository) DeleteByObjectTypeAndId ¶
func (PostgresRepository) DeleteWarrantsMatchingObject ¶
func (PostgresRepository) DeleteWarrantsMatchingSubject ¶
func (PostgresRepository) GetByObjectTypeAndId ¶
func (PostgresRepository) List ¶
func (repo PostgresRepository) List(ctx context.Context, filterOptions *FilterOptions, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)
func (PostgresRepository) UpdateByObjectTypeAndId ¶
type SQLiteRepository ¶
type SQLiteRepository struct {
database.SQLRepository
}
func NewSQLiteRepository ¶
func NewSQLiteRepository(db *database.SQLite) *SQLiteRepository
func (SQLiteRepository) BatchGetByObjectTypeAndIds ¶
func (SQLiteRepository) DeleteByObjectTypeAndId ¶
func (SQLiteRepository) DeleteWarrantsMatchingObject ¶
func (SQLiteRepository) DeleteWarrantsMatchingSubject ¶
func (SQLiteRepository) GetByObjectTypeAndId ¶
func (SQLiteRepository) List ¶
func (repo SQLiteRepository) List(ctx context.Context, filterOptions *FilterOptions, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)
func (SQLiteRepository) UpdateByObjectTypeAndId ¶
type Service ¶ added in v0.41.0
type Service interface { Create(ctx context.Context, objectSpec CreateObjectSpec) (*ObjectSpec, error) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (*ObjectSpec, error) BatchGetByObjectTypeAndIds(ctx context.Context, objectType string, objectIds []string) ([]ObjectSpec, error) List(ctx context.Context, filterOptions *FilterOptions, listParams service.ListParams) ([]ObjectSpec, *service.Cursor, *service.Cursor, error) UpdateByObjectTypeAndId(ctx context.Context, objectType string, objectId string, updateSpec UpdateObjectSpec) (*ObjectSpec, error) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (*wookie.Token, error) }
type UpdateObjectSpec ¶
type UpdateObjectSpec struct {
Meta map[string]interface{} `json:"meta"`
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.