class Paper(StructuredNode): """Represents a Paper node in Neo4j""" __name__ = 'Paper' PaperId = IntegerProperty(unique_index=True) Rank = IntegerProperty() DOI = StringProperty() Doctype = StringProperty() name = StringProperty(index=True) label = StringProperty() Year = IntegerProperty() Date = DateProperty() Publisher = StringProperty() Volume = StringProperty() Issue = StringProperty() FirstPage = StringProperty() LastPage = StringProperty() ReferenceCount = IntegerProperty() CitationCount = IntegerProperty() abstract = StringProperty() source = StringProperty() prob = FloatProperty() community = IntegerProperty() UpdatedAt = DateProperty() Id = AliasProperty(to='PaperId') CC = AliasProperty(to='CitationCount') RC = AliasProperty(to='ReferenceCount') authors = RelationshipTo('.author.Author', 'HAS_AUTHOR') fields = RelationshipTo('.field.FieldOfStudy', 'HAS_FIELD') references = RelationshipTo('.paper.Paper', 'CITES') cited_by = RelationshipFrom('.paper.Paper', 'CITES')
class Author(StructuredNode): """Represents an Author node in Neo4j""" __name__ = 'Author' AuthorId = IntegerProperty(index=True) Rank = IntegerProperty() name = StringProperty(index=True) label = StringProperty() PaperCount = IntegerProperty() CitationCount = IntegerProperty() UpdatedAt = DateProperty() Id = AliasProperty(to='AuthorId') papers = RelationshipFrom('.paper.Paper', 'HAS_AUTHOR')
class FieldOfStudy(StructuredNode): """Represents an Author node in Neo4j""" __name__ = "FieldOfStudy" FieldOfStudyId = IntegerProperty(index=True) Rank = IntegerProperty() name = StringProperty(index=True) label = StringProperty() MainType = StringProperty() Level = IntegerProperty() PaperCount = IntegerProperty() CitationCount = IntegerProperty() UpdatedAt = DateProperty() Id = AliasProperty(to='FieldOfStudyId') papers = RelationshipFrom('.paper.Paper', 'HAS_FIELD') child = RelationshipTo('.field.FieldOfStudy', 'HAS_CHILD') parent = RelationshipFrom('.field.FieldOfStudy', 'HAS_CHILD')
class User(SerializableStructuredNode): """ This is an example class for showing how a SerializableStructuredNode is put together. ALL rules for StructuredNode\ apply to SerializableStructuredNode. Please refer to the NeoModel documentation at \ http://neomodel.readthedocs.org/en/latest/. """ __type__ = 'users' # => __type__ must be specified and the same as the default for type # INFO version = '1.0.0' # => A version is not required but is a good idea secret = [ 'password' ] # => Variable names listed in this list don't show up in resource objects returned by the API hashed = [ 'password' ] # => Variable names listed in this list are encrypted using sha256 enums = { 'gender': ['m', 'f', 'o'] } # => Enums in this dictionary can only be dates = [ 'birthday' ] # => Format datetime object as date because datetime.date objects cannot be json encoded # ATTRIBUTES -- NOTE: 'type' and 'id' are required for json api specification compliance type = StringProperty( default='users') # => required, unique name for model id = StringProperty(unique_index=True, required=True) # => required email = AliasProperty(to='id') password = StringProperty(required=True) gender = StringProperty() # RELATIONSHIPS friends = Relationship( 'User', 'HAS_FRIEND', model=FriendRel) # => for all relationships a model must be chosen mom = RelationshipTo('User', 'HAS_MOM', cardinality=ZeroOrOne, model=SerializableStructuredRel)
class NodeTest(TimestampedNode): p_str = StringProperty(required=True) p_int = IntegerProperty() p_arr = ArrayProperty() p_json = JSONProperty() p_float = FloatProperty() p_date = DateProperty() p_dt = DateTimeProperty() p_bool = BooleanProperty() p_alias = AliasProperty() test1 = RelationshipFrom( "restapi.connectors.neo4j.models.User", "TEST", cardinality=ZeroOrMore, model=RelationTest, ) test2 = RelationshipFrom( "restapi.connectors.neo4j.models.User", "TEST2", cardinality=ZeroOrMore, model=RelationTest, )
class AliasTestNode(StructuredNode): name = StringProperty(unique_index=True) full_name = AliasProperty(to='name') long_name = MagicProperty(to='name')
class ProficiencyRel(StructuredRel): year = IntegerProperty(required=True) score = FloatProperty(required=True) name = AliasProperty(to="year") # demonstrates alias creation for property