1from flask import Flask
2from flask.ext.mongoalchemy import MongoAlchemy
3app = Flask(__name__)
4app.config['MONGOALCHEMY_DATABASE'] = 'library'
5db = MongoAlchemy(app)
6
7class Author(db.Document):
8 name = db.StringField()
9
10class Book(db.Document):
11 title = db.StringField()
12 author = db.DocumentField(Author)
13 year = db.IntField()
14