我已经在couchdbkit中遇到过很多 - 据我所知,在couchdbkit下的子对象文档对象没有可以引用的父对象。我希望我是错的:有没有办法在couchdbkit中查找父对象?
class Child(DocumentSchema):
name = StringProperty()
def parent(self):
# How do I get a reference to the parent object here?
if self.parent.something:
print 'yes'
else:
print 'no'
class Parent(Document):
something = BooleanProperty()
children = SchemaListProperty(Child)
doc = Parent.get('someid')
for c in doc.children:
c.parent()
现在,我一直在做的就是绕过父对象,但我不喜欢这种方式。