File: getters.py

package info (click to toggle)
python-beanie 2.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,496 kB
  • sloc: python: 14,596; makefile: 6; sh: 6
file content (28 lines) | stat: -rw-r--r-- 674 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from abc import abstractmethod

from pymongo.asynchronous.collection import AsyncCollection

from beanie.odm.settings.base import ItemSettings


class OtherGettersInterface:
    @classmethod
    @abstractmethod
    def get_settings(cls) -> ItemSettings:
        pass

    @classmethod
    def get_pymongo_collection(cls) -> AsyncCollection:
        return cls.get_settings().pymongo_collection

    @classmethod
    def get_collection_name(cls) -> str:
        return cls.get_settings().name  # type: ignore

    @classmethod
    def get_bson_encoders(cls):
        return cls.get_settings().bson_encoders

    @classmethod
    def get_link_fields(cls):
        return None