Collection
- class deker.collection.Collection(name, schema, adapter, factory, storage_adapter, collection_options=None)
Bases:
SelfLoggerMixin,SerializerCollection of
ArraysorVArrays.Collectionis a high-level object for managing contents of a set ofArraysorVArraysunited into one group under collection name and certain schema.Properties
name: returnsCollectionnamearray_schema: returns schema of embeddedArraysvarray_schema: returns schema ofVArraysif applicable, else Nonepath: returns storage path to theCollectionoptions: returns chunking and compression optionsas_dict: serializes main information aboutCollectioninto dictionary, prepared for JSON
API methods
create: according to main schema creates newArrayorVArrayof storage and returns its objectclear: according to main schema removes allVArraysand/orArraysfrom the storagedelete: removesCollectionand all itsVArraysand/orArraysfrom the storagefilter: filtersArraysorVArraysaccording to main schema and provided conditions__iter__: according to the collection’s main schema iterates over allArraysorVArraysinCollection, yields their objects__str__: ordinary behaviour__repr__: ordinary behaviour
- clear()
Clear all
Arraysand/orVArraysinsideCollection.- Return type
None
- create(primary_attributes=None, custom_attributes=None, id_=None)
Create
ArrayorVArrayaccording to collection main schema.If
VArraySchemais passed toCollection, all data management will go throughVArraysas this method will create justVArrays(Arrayswill be created automatically byVArray). Otherwise, onlyArrayswill be created.
- delete()
Remove
Collectionand all its contents from the database.- Return type
None
- filter(filters)
Filter
ArraysorVArraysby provided conditions.- Parameters
filters (dict) – query conditions for filtering
- Return type
Note
Conditions for filtering are either Array or VArray
idvalue:{"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
Collectionto dictionary.
- property name: str
Get collection name.
- property options: Optional[BaseCollectionOptions]
Get collection options: chunking, compression, etc.
- property path: Path
Get
Collectionfs-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]) –