Skip to content

Commit b4f9228

Browse files
committed
Update annotations.md
1 parent 26b5e62 commit b4f9228

File tree

1 file changed

+91
-6
lines changed

1 file changed

+91
-6
lines changed

doc/annotations.md

Lines changed: 91 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,112 @@
11
# Annotations
2+
To define entities using annotations, add the following use-statement on top (as known from Doctrine ORM):
3+
4+
```php
5+
use HireVoice\Neo4j\Annotation as OGM;
6+
```
27

38
## @OGM\Entity
49

5-
### Custom repository classes
10+
```php
11+
/**
12+
* @OGM\Entity()
13+
*/
14+
class MyEntity
15+
{
16+
// definition
17+
}
18+
```
619

7-
As in Doctrine ORM, you can use your own, custom repository class:
20+
### Custom repository classes
821

922
```php
1023
/**
1124
* @OGM\Entity(repositoryClass="Repository\UserRepository")
1225
*/
26+
class MyEntityWithCustomRepository
27+
{
28+
// definition
29+
}
1330
```
1431

1532
### Node Labels
1633

17-
For adding labels to nodes, use the constructor of the ```@OGM\Entity``` annotation:
18-
1934
```php
2035
/**
2136
* @OGM\Entity(labels="Location,City")
2237
*/
23-
class User
38+
class MyLabeledEntity
2439
{
2540
//...
2641
}
27-
```
42+
```
43+
44+
## @OGM\Auto
45+
46+
This is used to define primary-keys automaticly.
47+
```php
48+
/**
49+
* @OGM\Auto
50+
*/
51+
protected $id;
52+
```
53+
54+
## @OGM\Property
55+
56+
Use this annotation to store the selected property into the neo4j graph.
57+
58+
```php
59+
/**
60+
* @OGM\Property
61+
*/
62+
protected $name;
63+
```
64+
65+
### Format
66+
67+
Optionally, a format can be defined. Default is scalar.
68+
69+
```php
70+
/**
71+
* @OGM\Property(format="date")
72+
*/
73+
protected $releaseDate;
74+
```
75+
76+
## @OGM\Index
77+
78+
Use this annotation to add a property to the (search) index. This can only be used along with @OGM\Property.
79+
80+
```php
81+
/**
82+
* @OGM\Property
83+
* @OGM\Index
84+
*/
85+
protected $name;
86+
```
87+
88+
## @OGM\ManyToOne
89+
90+
Defines a many to one relation.
91+
92+
```php
93+
/**
94+
* @OGM\ManyToOne
95+
*/
96+
protected $mainActor;
97+
```
98+
99+
### Relation
100+
101+
Optionally, a relation name can be defined.
102+
103+
```php
104+
/**
105+
* @OGM\ManyToOne(relation="acts-in")
106+
*/
107+
protected $mainActor;
108+
```
109+
110+
## @OGM\ManyToMany
111+
112+
Defines a many to many relation. Configuration is the same as @OGM\ManyToOne

0 commit comments

Comments
 (0)