neomodel icon indicating copy to clipboard operation
neomodel copied to clipboard

How to get Node label?

Open MrAsimZahid opened this issue 2 years ago • 1 comments

I have Nodes available but I don't know the label. How do I get the node label of a given node?

This functionality is available in cypher like following

label(node)

Returns:

node label

Thank you.

MrAsimZahid avatar Apr 22 '22 11:04 MrAsimZahid

Suppose I have the following models from the documentation.

class FriendRel(StructuredRel):
    since = DateTimeProperty(
        default=lambda: datetime.now(pytz.utc)
    )
    met = StringProperty()

class Person(StructuredNode):
    name = StringProperty()
    friends = RelationshipTo('Person', 'FRIEND', model=FriendRel)

With the following data.

>>> bob = Person(name='bob').save()

To get bob's labels, simply use the following:

>>> bob.labels()
['Person']

Enprogames avatar Jun 14 '22 15:06 Enprogames

Thank you @Enprogames, I'll close this issue!

AntonLydike avatar Sep 17 '22 12:09 AntonLydike