Strange error with autoincrement id
thanosalexander opened this issue · 3 comments
I have a Post model and when i create a new one
App\Post::create([
'body'=>'test'
])
i receive strange ids
eg for past posts i have id 1186514 and for a newer one i have 1186487 which is lower , so i face huge problem in sorting
Hey,
this is due to neo4j internal ids. As you can read here:
https://stackoverflow.com/questions/30753560/should-we-use-the-neo4j-internal-id
it is not recommended to use internal ids, as they can be reused, like it happened in your example.
Obviously they are only reused after node/relationship is deleted.
You should either associate your own ids to nodes, and use them as autoincrement, or sort them using created_at column.
Hi .. sure its a solution but it's not too much safe as maybe some other instance will be created at same time (second level).. so which one will be sorted first?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.