Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions server/common/entitystore.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#
# Copyright (c) 2016-2018, creative.ai GmbH.
#
from typing import NewType
from server.common.service import Service
from server.common.postgres.service import Postgres


EntityFilter = NewType('EntityFilter', dict[str, bool])
EntityId = NewType('EntityId', str)
Entity = NewType('Entity', dict)


class Entitystore(Service):
child_services = {
"postgres": Postgres
}

def create(data: dict) -> Entity:
raise NotImplementedError

def read(id: str) -> Entity:
raise NotImplementedError

def update(id: EntityId, data: dict) -> Entity:
raise NotImplementedError

def delete(id: EntityId) -> Entity:
raise NotImplementedError

def list(filter: EntityFilter) -> list[Entity]:
raise NotImplementedError

# here for completeness sake, but shouldn't be used when creating child entities
# because it's not atomic, use create_child
def connect(parent: EntityId, child: EntityId) -> bool:
raise NotImplementedError

def disconnect(parent: EntityId, child: EntityId) -> bool:
raise NotImplementedError

def create_child(id: EntityId, data: dict) -> Entity:
raise NotImplementedError

def list_children(filter: EntityFilter) -> list[Entity]:
raise NotImplementedError