neo4j-php-ogm icon indicating copy to clipboard operation
neo4j-php-ogm copied to clipboard

Multiple labels for a node

Open fre5h opened this issue 8 years ago • 2 comments

I didn't find possibility to add multiple labels for a node. For example, I have a base node Stop then I have inherited nodes like BusStop, TramStop, TrolleybusStop. I need that stops for trolleybus have two labels (Stop:TrolleybusStop). As I understood it is impossible now to do this. Am I right?

I would like to have something like this

  1. array of labels in annotation @OGM\Node(labels={"Stop", "TrolleybusStop"})

  2. or like this

/**
 * @OGM\Node(label="Stop")
 */
class Stop
{
}

/**
 * @OGM\Node(label="TrolleybusStop")
 */
class TrolleybusStop extends Stop
{
    // This entity should have both labels: Stop and TrolleybusStop.
    // Because first one should be inherited from the parent class.
}

fre5h avatar Jan 29 '17 12:01 fre5h

It is impossible to do it with inheritance. I agree it should be add when mapping inheritance will be in place.

In the meantime what you can do is add a @Label on a boolean property :


/**
 * @OGM\Label(name="Stop")
*/
protected $isTrolley = true;

This is hacky but will work

ikwattro avatar Feb 23 '17 19:02 ikwattro

While I understand the need, the way I would like to be achieved would require a bit time and development so I decided to plan this feature post GA release and spend more time on stability and the UOW refactoring which are more critical for now.

You can still use the trick I posted. Note though that having inherited labels in Neo4j is a bit useless because you have the same metadata implicitly from the relationships.

ikwattro avatar Mar 31 '17 22:03 ikwattro