Open matejcik opened 12 years ago
This is the attended behavior. u2.description should return the filled value. What's wrong ?
well, it doesn't. (in MongoKit 0.7.2 at least)
with the proposed enhancement, the following code would work:
from mongokit import Document
from mongokit import Connection as KitCon
from pymongo import Connection as MoCon
mc = MoCon()
kc = KitCon()
# create an "unexpected" record directly through PyMongo
mc.example.drop_collection('users')
mtable = mc.example.users
mtable.insert({'name':'hello','password':'world'})
@kc.register
class User(Document):
__collection__ = 'users'
structure = {
'name': unicode,
'password': unicode,
'description': unicode,
}
default_values = { 'description': u'hello world' }
user = kc.example.User.find_one()
assert user['description'] == u'hello world'
it would be nice to have something like this:
this looks like a nice alternative to migration suppport for schemaless documents