Skip to content

Overview

Data structures relationships made easy

build codecov

Note

corm is in early development. API can change.

Installation

pip install corm

Example

from corm import Storage, Entity, Nested, Relationship


class Address(Entity):
    street: str
    number: int
    user: 'User' = Relationship(entity_type='User')

class User(Entity):
    name: str
    address: Address = Nested(entity_type=Address, back_relation=True)


storage = Storage()
john = User(
    data={'name': 'John', 'address': {'street': 'First', 'number': 1}},
    storage=storage,
)

assert john.address.street == 'First'
assert john.address.number == 1
assert john.address.user is john