from mongoframes import *

# Define some document frames (a.k.a models)
class Dragon(Frame):
    _fields = {'name', 'loot'}

class Item(Frame):
    _fields = {'desc', 'worth'}

# Create a dragon and loot to boot
Item(desc='Sock', worth=1).insert()
Item(desc='Diamond', worth=100).insert()
Dragon(name='Burt', loot=Item.many()).insert()

# Have Burt boast about his loot
burt = Dragon.one(Q.name == 'Burt', projection={'loot': {'$ref': Item}})
for item in burt.loot:
    print('I have a {0.desc} worth {0.worth} crown'.format(item))

Features

  • Simple schemas
  • Dot notation
  • Friendly queries
  • Pagination
  • Fast dereferencing
  • Event hooks
  • Test suite
  • Documentation
  • Python 3.4+

Thanks to...

David Bailey, Nick Snell, Guillaume Piot and Andy Blackshaw for your input, feedback and insights. Ross Tarran for help with documentation, and lastly Burt for sticking with me since FSM.