File: reference.py

package info (click to toggle)
python-odmantic 1.0.2%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,756 kB
  • sloc: python: 8,547; sh: 37; makefile: 34; xml: 13; javascript: 3
file content (23 lines) | stat: -rw-r--r-- 485 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from typing import Any, Optional


def Reference(*, key_name: Optional[str] = None) -> Any:
    """Used to define reference fields.

    Args:
        key_name: name of the Mongo key that stores the foreign key

    <!--
    #noqa: DAR201
    -->
    """
    return ODMReferenceInfo(key_name=key_name)


class ODMReferenceInfo:
    """Extra data for an ODM reference."""

    __slots__ = ("key_name",)

    def __init__(self, key_name: Optional[str]):
        self.key_name = key_name