Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/mongo/models/entity.py
- This file was added.
from abc import ABCMeta | |||||
class Entity: #(ABCMeta): | |||||
""" | |||||
An object saved in the db | |||||
""" | |||||
collection: str | |||||
model: dict | |||||
validate_model: bool | |||||
def __init__(self, db): | |||||
self.db = db | |||||
self.db_collection = self.db.get_collection(self.collection) | |||||
def bulk_write(self, writes): | |||||
self.db_collection.bulk_write(writes) | |||||
# def _load_model(self): | |||||
# return {} | |||||
# def _set_data(self, data): | |||||
# pass | |||||
# def _validate(self): | |||||
# self.db.command() # use json in schema.json | |||||
# def save(self): | |||||
# if self.validate_model and self._validate(): | |||||
# raise DataError() | |||||
# save() | |||||
# def get(self, qry): | |||||
# pass | |||||
# def _is_older_in_time(self): | |||||
# return self.data.ts < ts | |||||
# def add_if_older(self): | |||||
# if _is_older(): | |||||
# self.save() | |||||
# def with_excetion_handle(self): | |||||
# pass | |||||
class EntityList: | |||||
""" | |||||
List or array of entities and their operations | |||||
Operate mostly on object cache | |||||
""" | |||||
pass |