Documentation
¶
Index ¶
- Constants
- Variables
- func BuildTypeObjectKey(typeID string) string
- func BuildTypeQuad(objKey, typeID string) quad.Quad
- func BuildTypeQuadValue(typeID string) quad.Value
- func CheckObjectType(ctx context.Context, ws world.WorldState, key, typeID string) error
- func EnsureTypeExists(ctx context.Context, ws world.WorldState, typeID string) (created bool, err error)
- func GetObjectType(ctx context.Context, ws world.WorldState, key string) (string, error)
- func IterateObjectsWithType(rctx context.Context, ws world.WorldState, typeID string, ...) error
- func LimitNodesToTypes(path *cayley.Path, typeIDs ...string) *cayley.Path
- func ListCollectObjectsWithType[T block.Block](ctx context.Context, ws world.WorldState, typeID string, ...) ([]T, []string, error)
- func ListObjectsWithType(ctx context.Context, ws world.WorldState, typeID string) ([]string, error)
- func SetObjectType(ctx context.Context, ws world.WorldState, key, typeID string) error
- type ObjectMetadata
Constants ¶
const TypesPrefix = "types/"
TypesPrefix is the prefix string for all types identifiers.
Variables ¶
var ( // ErrTypeIDEmpty is returned if the given type ID was empty.TypeIDEmpty is returned if the given type ID was empty. ErrTypeIDEmpty = errors.New("type ID empty") // ErrUnknownObjectType indicates the object type was not known. ErrUnknownObjectType = errors.New("unknown object type") )
var TypePred quad.Value = quad.IRI("type")
TypePred is the predicate linking a object to its type.
Functions ¶
func BuildTypeObjectKey ¶
BuildTypeObjectKey returns the object key referring to the type.
func BuildTypeQuad ¶
BuildTypeQuad returns a type quad for a key and type.
func BuildTypeQuadValue ¶
BuildTypeQuadValue returns the quad value referring to the type.
func CheckObjectType ¶
CheckObjectType asserts that the object key exists and has the given type.
func EnsureTypeExists ¶
func EnsureTypeExists(ctx context.Context, ws world.WorldState, typeID string) (created bool, err error)
EnsureTypeExists creates the object representing the type ID if it doesn't exist.
func GetObjectType ¶
GetObjectType returns the type of a given object. Returns "" if the object has no type.
func IterateObjectsWithType ¶
func IterateObjectsWithType( rctx context.Context, ws world.WorldState, typeID string, cb func(objKey string) (bool, error), ) error
IterateObjectsWithType iterates over object keys with the given type ID.
func LimitNodesToTypes ¶
LimitNodesToTypes limits the matched nodes to the given types in the Path.
func ListCollectObjectsWithType ¶
func ListCollectObjectsWithType[T block.Block](ctx context.Context, ws world.WorldState, typeID string, ctor func() block.Block) ([]T, []string, error)
ListCollectObjectsWithType returns the list of object keys with the given type id. Unmarshals the bodies of the matched objects.
ctor must return an object of type T returns two slices of length objKeys if any objects are not found, returns nil for that object state / value and objs, objsStates, ErrNotFound returns nil, nil, err for any other error
func ListObjectsWithType ¶
ListObjectsWithType returns the list of object keys with the given type id.
func SetObjectType ¶
SetObjectType sets the type of a given object by writing a graph quad.
Types ¶
type ObjectMetadata ¶
type ObjectMetadata struct {
// ObjectKey is the object key.
ObjectKey string
// TypeID is the type of the object, empty if none.
TypeID string
// ParentObjectKey is the parent object key, empty if none.
ParentObjectKey string
}
ObjectMetadata holds the type and parent metadata for a single object.
func GetObjectMetadataBatch ¶
func GetObjectMetadataBatch(ctx context.Context, ws world.WorldState, keys []string) ([]*ObjectMetadata, error)
GetObjectMetadataBatch returns the type and parent metadata for a list of object keys using indexed graph passes within a single Cayley transaction rather than 2N individual lookups.
The result slice preserves the input key order.