jur9526 / couchdb-python

Automatically exported from code.google.com/p/couchdb-python
Other
0 stars 0 forks source link

Feature: Document model referencing #145

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Feature discussion and description: 
http://groups.google.ru/group/couchdb-python/browse_thread/thread/9276b4aad7845b
d9?hl=ru

Usage example:
class Author(Document):
  name = TextField()

class Post(Document):
  author = DocumentRefField(Author)

post = Post()
post.author(id='Mike')
post.author.name = 'Mike'
# -- or --
post.author = Author(id='Jan', name='Jan')

# loading document with all references:
post = Post.load(db, post_id, recursive=True)

# storing document and all referenced ones:
post.store(db, recursive=True)

# new feature - in place reloading:
post.author.reload(db) # so we get latest version of referenced document

# if we dont wants to resolve all references now, but later - yes:
post = Post.load(db)
assert post.author.name is None
post.author.resolve(db)
assert post.author.name is not None

Feature is quite alpha, but it works(: I'll use it in my own projects, because 
I very need it, so this is not final state of patch.

Original issue reported on code.google.com by kxepal on 5 Aug 2010 at 6:20

Attachments:

GoogleCodeExporter commented 9 years ago
Time had showed that this way is really buggy and requires to change a lot of 
code to made it works fair stable. I'll have to try to find another way.

Original comment by kxepal on 12 Feb 2011 at 7:13

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub. Please continue discussion here:

https://github.com/djc/couchdb-python/issues/145

Original comment by djc.ochtman on 15 Jul 2014 at 7:19