amark / gun

An open source cybersecurity protocol for syncing decentralized graph data.
https://gun.eco/docs
Other
18.12k stars 1.16k forks source link

Deleting (setting Null) is not working properly #954

Open haynajjar opened 4 years ago

haynajjar commented 4 years ago

I use gun 0.2020.430

When i try to delete a node and then use the same path to add new values, I get the following strange result,

Delete bug

Is there any other proper way we can use it to delete nodes and use them later?

sirpy commented 4 years ago

@amark the new null behaviour needs to be documented somewhere @haynajjar in order to delete you can:

  1. set each primitive value to null
  2. set list to a new node ie .get('list').put(gun.get(mynewnodesoul))
  3. dont delete, or use some kind of a deleted flag
haynajjar commented 4 years ago

Thank you @sirpy

The second option may work for me with some workaround. Still, it would be great if there is a way to reuse the same path even after setting null.

It seems Gun no longer generates unique ids for paths, therefore it will update the same souls' data each time we try to "put". That may have created an inversion of control from Gun to the user in order to manage his own souls and make Gun faster. But it has created other problems concerning replacing data.

Maybe Gun can add some options to choose to generate a new soul with some prefix.

I don't know, maybe I am missing something, I hope this matter is under consideration.

sirpy commented 4 years ago

@amark could probably shed some light on this