Beispiel #1
0
    def resolve_accounts(self, info, args):
        qs = AccountModel.objects()

        meta = args.get('meta', {})
        not_null = meta.get('not_null')

        if not_null:
            qs = qs.filter(
                __raw__={f'json_metadata.{not_null}': {
                    '$exists': True
                }})

        return qs
Beispiel #2
0
    def create_account_by_chat_id(self, chat_id: str, username: str):
        session = Session()

        instance = session.query(AccountModel).filter_by(
            chat_id=chat_id, ).one_or_none()
        if instance:
            return

        account_model = AccountModel(chat_id=chat_id, username=username)

        try:
            session.add(account_model)
            session.commit()
        except Exception:
            session.rollback()
Beispiel #3
0
 def resolve_voter(self, info):
     return AccountModel.objects().get(name=self['voter'])
Beispiel #4
0
 def resolve_author(self, info):
     return AccountModel.objects(name=self.author).first()
Beispiel #5
0
 def resolve_account(self, info, name):
     return AccountModel.objects(name=name).first()