neo4j-contrib / neomodel

An Object Graph Mapper (OGM) for the Neo4j graph database.
https://neomodel.readthedocs.io
MIT License
939 stars 231 forks source link

Database introspection #755

Closed mariusconjeaud closed 10 months ago

mariusconjeaud commented 11 months ago

It could be useful to have a script that can connect to a database, read the schema, and propose neomodel class definitions based on that.

I have written a first version of this that I will share soon.

It returns something like the below. Of course, it will have limitations, especially with multi-label nodes, and relationship cardinality. But this can be a good way to kickstart a neomodel project on top of an existing database

class Content(StructuredNode):
    updated = StringProperty()
    embedding = StringProperty()
    title = StringProperty()
    url = StringProperty()
    description = StringProperty()
    created = StringProperty()
    thumbnail = StringProperty()
    id = StringProperty()
    format = StringProperty()
    language = StringProperty()
    tagged = RelationshipTo(Keyword, "tagged")

class Author(StructuredNode):
    name = StringProperty(index=True)
    authored = RelationshipTo(Content, "authored")

class Keyword(StructuredNode):
    name = StringProperty(index=True)
mariusconjeaud commented 10 months ago

Part of release 5.2.0