jeffjenkins/MongoAlchemy — Issue #76: collection name should not necessary be based on class name
Author: nsteinmetz
Created: 2011-10-22 21:19:16+00:00
State: open

Hello,

If I understood well, the collection name is based on the class name. Which may make sense most of the time but I would have prefered them not to be tied. If you want to reuse some code throught several applications, it may be better to set collections on your own and not automatically.

For this, I think that MongoKit have a nice way to implement it :

```python
class BlogPost(Document):
__collection__ = 'blog_posts'
__database__ = 'tutorial
structure = {
'title':unicode,
'body':unicode,
'author':unicode,
'date_creation':datetime.datetime,
'rank':int,
'tags': [unicode],
}
required_fields = ['title','author', 'date_creation']
default_values = {'rank':0, 'date_creation':datetime.datetime.utcnow}
```

Would it be possible in MongoAlchemy (which I find more complete for other stuff and with Flask-MongoAlchemy ;-) )?