Skip to content

Latest commit

 

History

History
112 lines (86 loc) · 1.45 KB

annotations.md

File metadata and controls

112 lines (86 loc) · 1.45 KB

Annotations

To define entities using annotations, add the following use-statement on top (as known from Doctrine ORM):

use HireVoice\Neo4j\Annotation as OGM;

@OGM\Entity

/**
 * @OGM\Entity()
 */
class MyEntity
{
    // definition
}

Custom repository classes

/**
 * @OGM\Entity(repositoryClass="Repository\UserRepository")
 */
class MyEntityWithCustomRepository
{
    // definition
}

Node Labels

/**
 * @OGM\Entity(labels="Location,City")
 */
class MyLabeledEntity
{
    //...
}

@OGM\Auto

This is used to define primary-keys automaticly.

/**
 * @OGM\Auto
 */
protected $id;

@OGM\Property

Use this annotation to store the selected property into the neo4j graph.

/**
 * @OGM\Property
 */
protected $name;

Format

Optionally, a format can be defined. Default is scalar.

/**
 * @OGM\Property(format="date")
 */
protected $releaseDate;

@OGM\Index

Use this annotation to add a property to the (search) index. This can only be used along with @OGM\Property.

/**
 * @OGM\Property
 * @OGM\Index
 */
protected $name;

@OGM\ManyToOne

Defines a many to one relation.

/**
 * @OGM\ManyToOne
 */
protected $mainActor;

Relation

Optionally, a relation name can be defined.

/**
 * @OGM\ManyToOne(relation="acts-in")
 */
protected $mainActor;

@OGM\ManyToMany

Defines a many to many relation. Configuration is the same as @OGM\ManyToOne