from api_graphql.abc.query_abc import QueryABC
from data.schemas.administration.user import User


class DbModelQueryABC(QueryABC):

    def __init__(self, name: str = __name__):
        QueryABC.__init__(self, name)

        self.set_field("id", lambda x, *_: x.id)
        self.set_field("deleted", lambda x, *_: x.deleted)
        self.set_field("editor", self.__get_editor)
        self.set_field("createdUtc", lambda x, *_: x.created)
        self.set_field("updatedUtc", lambda x, *_: x.updated)

    @staticmethod
    async def __get_editor(x: User, *_):
        return await x.editor
