Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Neo4j Driver Integration
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
MikroORM currently supports SQL databases (PostgreSQL, MySQL, MariaDB, SQLite, MSSQL) and MongoDB as a document database. However, there is no native support for graph databases, which are increasingly important for modeling complex relationships and interconnected data structures such as social networks, recommendation engines, knowledge graphs, and organizational hierarchies.
Issue/Discussion: #4674
What is the new behavior?
This PR introduces comprehensive Neo4j graph database support to MikroORM through a new
@mikro-orm/neo4jdriver package.Key Features:
Complete Graph Database Support
neo4j-driverGraph-Specific Decorators
@Node()- Marks entities as Neo4j nodes with optional multiple labels@Rel()- Defines relationships with explicit type and direction (IN/OUT)@RelationshipProperties()- Enables relationships with rich metadata@Field()- Alias for@Property()providing graph-style syntaxAdvanced Query Builder
@neo4j/cypher-builderlibraryRelationship Modeling
Virtual Entities
Raw Cypher Execution
em.run()method for executing raw Cypher queriesem.aggregate()for aggregation queriesUsage Examples:
Basic Node Definition:
Multiple Labels:
Relationships:
Relationship Properties:
Query Builder:
Raw Cypher:
Virtual Entities:
Transactions:
Implementation Details:
New Package Structure:
Core Components:
DatabaseDriverinterface with graph-specific operationsrun(),aggregate(), andcreateQueryBuilder()@neo4j/cypher-builderwith MikroORM entity awarenessMetadata Storage:
WeakMapto avoid interfering with MikroORM's core metadata@Node()stores additional labels on entity metadata@Rel()stores relationship type and direction for properties@RelationshipProperties()marks entities as relationship entitiesType Conversions:
Does this PR introduce a breaking change?
This is a new feature that adds Neo4j support without affecting any existing functionality:
@mikro-orm/neo4jpackageOther information
Benefits:
Native Graph Database Support
Familiar MikroORM API
find(),create(),flush(),remove()patternstransactional()andbegin()/commit()Flexible Querying
Rich Relationship Modeling
Production Ready
Testing:
Comprehensive Test Suite (
tests/features/neo4j/Neo4jDriver.test.ts):@Reldecorator@Node({ labels: [...] })@RelationshipPropertiesem.run()em.aggregate()Test Coverage:
Documentation:
New Documentation (
docs/docs/usage-with-neo4j.md):@Node(),@Field(),@Rel()@RelationshipProperties()Documentation Style:
usage-with-mongo.mdConfiguration Example:
Dependencies:
neo4j-driver(^5.25.0) - Official Neo4j JavaScript driver@neo4j/cypher-builder(^1.2.3) - Official Cypher query builderFuture Enhancements:
Potential future improvements (not included in this PR):
Migration Path:
For users wanting to adopt Neo4j:
Install the package:
Update configuration:
Add graph decorators:
Use as normal:
Comparison with Other Drivers:
Related Issues/Discussions:
This PR represents a significant expansion of MikroORM's capabilities, bringing professional graph database support to the ecosystem while maintaining the familiar and beloved MikroORM API patterns.