Collection
- class deker.collection.Collection(name, schema, adapter, factory, storage_adapter, collection_options=None)
Bases:
SelfLoggerMixin
,Serializer
Collection of
Arrays
orVArrays
.Collection
is a high-level object for managing contents of a set ofArrays
orVArrays
united into one group under collection name and certain schema.Properties
name
: returnsCollection
namearray_schema
: returns schema of embeddedArrays
varray_schema
: returns schema ofVArrays
if applicable, else Nonepath
: returns storage path to theCollection
options
: returns chunking and compression optionsas_dict
: serializes main information aboutCollection
into dictionary, prepared for JSON
API methods
create
: according to main schema creates newArray
orVArray
of storage and returns its objectclear
: according to main schema removes allVArrays
and/orArrays
from the storagedelete
: removesCollection
and all itsVArrays
and/orArrays
from the storagefilter
: filtersArrays
orVArrays
according to main schema and provided conditions__iter__
: according to the collection’s main schema iterates over allArrays
orVArrays
inCollection
, yields their objects__str__
: ordinary behaviour__repr__
: ordinary behaviour
- clear()
Clear all
Arrays
and/orVArrays
insideCollection
.- Return type
None
- create(primary_attributes=None, custom_attributes=None, id_=None)
Create
Array
orVArray
according to collection main schema.If
VArraySchema
is passed toCollection
, all data management will go throughVArrays
as this method will create justVArrays
(Arrays
will be created automatically byVArray
). Otherwise, onlyArrays
will be created.
- delete()
Remove
Collection
and all its contents from the database.- Return type
None
- filter(filters)
Filter
Arrays
orVArrays
by provided conditions.- Parameters
filters (dict) – query conditions for filtering
- Return type
Note
Conditions for filtering are either Array or VArray
id
value:{"id": "some_array_UUID_string"}
or full scope of primary attributes’ values:
{"primary_attr1_name": its value, "primary_attr2_name": its value, ...}
- property array_schema: ArraySchema
Get collection
ArraySchema
.
- property arrays: ArrayManager
Return manager for
Arrays
.
- property as_dict: dict
Serialize
Collection
to dictionary.
- property name: str
Get collection name.
- property options: Optional[BaseCollectionOptions]
Get collection options: chunking, compression, etc.
- property path: Path
Get
Collection
fs-path.
- property varray_schema: Optional[VArraySchema]
Get collection
VArraySchema
.
- property varrays: Optional[VArrayManager]
Return manager for
VArrays
.
- Parameters
name (str) –
schema (Union[ArraySchema, VArraySchema]) –
adapter (BaseCollectionAdapter) –
factory (BaseAdaptersFactory) –
storage_adapter (Type[BaseStorageAdapter]) –
collection_options (Optional[BaseCollectionOptions]) –