4

how is it possible in neomodel to share a unique index across node objects, without instantiating separate objects to just hold the indexed data? I'd like to find the object based on a index query, e.g like this:

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

with

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
Nicholas
  • 7,403
  • 10
  • 48
  • 76
bebbi
  • 2,489
  • 3
  • 22
  • 36
  • "neomodel" doesn't exist as a tag... maybe if one of the bigmen is kind enough to help out.. ;) – bebbi Jul 15 '13 at 13:13

1 Answers1

2

In https://github.com/robinedwards/neomodel/commit/1f1b43377b25cd4d41e17ce2b7f9ca1a1643edea it was added support for custom index on StructuredNode subclasess

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
Neoecos
  • 569
  • 4
  • 16