0

I have a neomodel Model:

from neomodel import StructuredNode, StringProperty, UniqueIdProperty, db

db.set_connection('bolt://neo4j:password@masir_neo4j:7687')

class City(StructuredNode):
    id = UniqueIdProperty()
    name = StringProperty(index=True, default="city")

I've installed labels to the neo4j database by this command which is represented in the neomodel's documentation:

neomodel_install_labels manage.py app.models --db bolt://neo4j:password@masir_neo4j:7687

After running this command the City node is added to the neo4j database, then I'm trying to add some data to the database by Python shell, here is the result:

enter image description here

But, as you can see there is nothing in the City node.

Then I tried to save data by cypher_query and it worked:

enter image description here

Why the save function of neomodel isn't working?

Hanie Asemi
  • 1,318
  • 2
  • 9
  • 23
  • 2
    Try removing `id = UniqueIdProperty()`. This is an internal neo4j property that as far as I know should not be on the class – nimrod serok May 07 '23 at 14:11

1 Answers1

0

According to https://neomodel.readthedocs.io/en/latest/properties.html

All nodes in neo4j have an internal id (accessible by the ‘id’ property in neomodel) however these should not be used by an application. Neomodel provides the UniqueIdProperty to generate unique identifiers for nodes (with a unique index)

So you can't have a property called id. You need to use a different property name, for example uid (anything other than id would work)

Alan Buxton
  • 186
  • 10