Skip to content
This repository has been archived by the owner on Apr 21, 2021. It is now read-only.

Proper Enum support #4

Open
ahopkins opened this issue May 26, 2019 · 0 comments
Open

Proper Enum support #4

ahopkins opened this issue May 26, 2019 · 0 comments

Comments

@ahopkins
Copy link
Owner

from enum import Enum, auto
from pydiggy import Node


class Fruit(Enum):
    APPLE = auto()
    BANANA = auto()
    POMEGRANATE = auto()



class Person(Node):
    name: str
    favorite_fruit: Fruit


> adam = Person(name="Adam", favorite_fruit=Fruit.POMEGRANATE)
> print(adam.name)
'Adam'
> print(adam.favorite_fruit)
Fruit.POMEGRANATE

This would be stored in dgraph as:

{
    set {
        <0x11> <Person> "true" .
        <0x11> <_type> "Person" .
        <0x11> <name> "Adam" .
        <0x11> <favorite_fruit>  "3"^^<xs:int> .
    }
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant