Company
Date Published
Author
Nigel Small
Word count
712
Language
English
Hacker News points
None

Summary

The py2neo Object-Graph Mapper (OGM) is a framework for building database-aware domain objects on top of graph databases like Neo4j, similar to how an Object-Relational Mapper (ORM) works with traditional relational databases. The OGM centres around the `GraphObject` class, which serves as both a base class and a manager for underlying node and relationships. Domain objects can be defined using this class, and properties are mapped to the corresponding nodes and relationships in the graph database. The framework also supports related objects through the use of `RelatedTo` and `RelatedFrom` attribute types, which define sets of related objects connected by specific relationship types. With py2neo OGM, developers can work with these objects using a set-like interface, adding and removing related objects, and pushing changes back into the graph database, where the framework automatically builds and runs necessary Cypher queries to make this happen. The framework also supports more complex selections through the `select` method, allowing for querying of nodes based on various conditions.