neo4j-contrib / django-neomodel

Neomodel plugin for Django
MIT License
290 stars 55 forks source link

how to get a instance with Increment id #65

Open shaojiajun314 opened 3 years ago

shaojiajun314 commented 3 years ago

How to do, i want to get a record with id, like cql "WHERE ID(n)=number"

shaojiajun314 commented 3 years ago

how to get a instance with Increment id

EvdH0 commented 3 years ago

To retrieve a node with an specific property see: https://neomodel.readthedocs.io/en/latest/getting_started.html#retrieving-nodes. As an example: jim = Person.nodes.get(name='Jim')

For indexing you can use UniqueIdProperty() https://neomodel.readthedocs.io/en/latest/module_documentation.html#neomodel.properties.UniqueIdProperty as shown here

shaojiajun314 commented 3 years ago

thanks. and i wanna ask another question. the id could be reuse, Is it the reason for the orm you coded, does not provided the api that i want?

whatSocks commented 3 years ago

@shaojiajun314 yes - for example if a node is deleted there could be a future node with the same internal id. This is why it is recommended for you to make your own domain-specific id field.