File tree 1 file changed +91
-6
lines changed 1 file changed +91
-6
lines changed Original file line number Diff line number Diff line change 1
1
# 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
+ ```
2
7
3
8
## @OGM \Entity
4
9
5
- ### Custom repository classes
10
+ ``` php
11
+ /**
12
+ * @OGM\Entity()
13
+ */
14
+ class MyEntity
15
+ {
16
+ // definition
17
+ }
18
+ ```
6
19
7
- As in Doctrine ORM, you can use your own, custom repository class:
20
+ ### Custom repository classes
8
21
9
22
``` php
10
23
/**
11
24
* @OGM\Entity(repositoryClass="Repository\UserRepository")
12
25
*/
26
+ class MyEntityWithCustomRepository
27
+ {
28
+ // definition
29
+ }
13
30
```
14
31
15
32
### Node Labels
16
33
17
- For adding labels to nodes, use the constructor of the ``` @OGM\Entity ``` annotation:
18
-
19
34
``` php
20
35
/**
21
36
* @OGM\Entity(labels="Location,City")
22
37
*/
23
- class User
38
+ class MyLabeledEntity
24
39
{
25
40
//...
26
41
}
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
You can’t perform that action at this time.
0 commit comments