Neomodel documentation¶
An Object Graph Mapper (OGM) for the Neo4j graph database, built on the awesome neo4j_driver
Familiar Django model style definitions.
Powerful query API.
Enforce your schema through cardinality restrictions.
Full transaction support.
Thread safe.
Async support.
pre/post save/delete hooks.
Django integration via django_neomodel
Requirements¶
For releases 5.x :
Python 3.7+
neo4j 5.x, 4.4 (LTS)
For releases 4.x :
Python 3.7 -> 3.10
Neo4j 4.x (including 4.4 LTS for neomodel version 4.0.10)
Installation¶
Install from pypi (recommended):
$ pip install neomodel
To install from github:
$ pip install git+git://github.com/neo4j-contrib/neomodel.git@HEAD#egg=neomodel-dev
Attention
New in 6.0
From now on, neomodel will use SemVer (major.minor.patch) for versioning.
This version introduces a modern configuration system, using a dataclass with typing, runtime and update validation rules, and environment variables support. See the Database Connection Setup section for more details.
This version introduces the merge_by parameter for batch operations to customize merge behaviour (label and property keys). See the batch section for more details.
Breaking changes in 6.0
The soft cardinality check is now available for all cardinalities, and strict check is enabled by default.
List object resolution from Cypher was creating “2-depth” lists for no apparent reason. This release fixes this so that, for example “RETURN collect(node)” will return the nodes directly as a list in the result. In other words, you can extract this list at results[0][0] instead of results[0][0][0]
AsyncDatabase / Database are now true singletons for clarity
- Standalone methods moved into the Database() class have been removed outside of the Database() class :
change_neo4j_password
clear_neo4j_database
drop_constraints
drop_indexes
remove_all_labels
install_labels
install_all_labels
Note : to call these methods with async, use the ones in the AsyncDatabase() _adb_ singleton.
Contents¶
- Getting started
- Connecting
- Querying the graph
- Defining Node Entities and Relationships
- Database Inspection - Requires APOC
- Applying constraints and indexes
- Remove existing constraints and indexes
- Generate class diagram
- Create, Update, Delete operations
- Retrieving nodes
- Relationships
- Retrieving additional relations
- Async neomodel
- Full example
- Relationships
- Property types
- Spatial Properties
- Schema management
- Filtering and ordering
- Path traversal
- Advanced query operations
- Semantic Indexes
- Cypher queries
- Transactions
- Hooks
- Batch node operations
- Configuration
- Extending neomodel
- General API
- Sync API Documentation
- Async API Documentation