Allow current_app.db('collections-name')

This mimics the use in Flamenco (current_flamenco.db('collection_name')),
and makes calling code a bit nicer (db('coll') instead of db()['coll'])
This commit is contained in:
Sybren A. Stüvel 2017-05-10 12:08:11 +02:00
parent 319f815985
commit a6617cae68

View File

@ -551,12 +551,14 @@ class PillarServer(Eve):
pprint(links)
def db(self):
def db(self, collection_name: str=None):
"""Returns the MongoDB database.
:rtype: flask_pymongo.PyMongo
"""
if collection_name:
return self.data.driver.db[collection_name]
return self.data.driver.db
def extension_sidebar_links(self, project):