gpt4 book ai didi

python - neomodel:如何在 StructuredNode 对象之间共享索引

转载 作者:太空宇宙 更新时间:2023-11-03 11:31:48 31 4
gpt4 key购买 nike

在 neomodel 中如何在节点对象之间共享唯一索引,而无需实例化单独的对象来仅保存索引数据?我想根据索引查询找到对象,例如:

...
mynode = BaseObject.index.get(uid=uid_of_Type1Object)
# mynode is now of type `Type1Object`

class BaseObject(StructuredNode):
uid = StringProperty(unique_index=True)
...

class Type1Object(BaseObject):
...
def assign_uid(self, guid):
# I may need tweaking of uid generator
# on subclass level
self.uid = guid

class Type2Object(BaseObject):
...
def assign_uid(self, guid):
self.uid = guid

最佳答案

https://github.com/robinedwards/neomodel/commit/1f1b43377b25cd4d41e17ce2b7f9ca1a1643edea添加了对 StructuredNode 子类自定义索引的支持

class BaseObject(StructuredNode):
__index__ = 'MyBaseIndex'
uid = StringProperty(unique_index=True)
...

class Type1Object(BaseObject):
__index__ = 'MyBaseIndex'
...
def assign_uid(self, guid):
# I may need tweaking of uid generator
# on subclass level
self.uid = guid

class Type2Object(BaseObject):
__index__ = 'MyBaseIndex'
...
def assign_uid(self, guid):
self.uid = guid

关于python - neomodel:如何在 StructuredNode 对象之间共享索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17654440/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com