Skip to content
Jesse Gibson edited this page Mar 7, 2016 · 8 revisions

Deleting Data from GUN

Gun takes a different approach to deletion than most other centralized services. Since other (potentially offline) peers might still have a copy of the node, removing your own copy is only temporary. As soon as that peer comes back online, the data will resynchronize and the node is back again. While this is pretty cool from the perspective of data recovery, it might be annoying if you're trying to get rid of something. This can be solved by replacing the references to the node with a different value, like a primitive or a pointer to different node.

var gun = Gun().get('data').put({
  object1: object2,
  object2: object2
})

// set 'object3' to a new node
gun.path('object3').put({
  field: 'value'
})

// replace the value at 'object3' with `null`
gun.path('object3').put(null)

// instead of pointing to an object, now it shows 'null'

As soon as the value is set, in this case null, the update propagates to each peer, breaking the reference to the old node. If storage space is a concern, a garbage collection module could be built on top of gun that removes data when it's sat on the shelf too long. At that point you might want to consider migrating to a hosted solution such as AWS, which has ridiculously cheap rates and oodles of storage space.

Another way of thinking about deletion is that you're not removing the data, but rather it's discoverability. It would be like Google removing a result from it's search. You can still enter the URL, but the website is effectively invisible.

If you have any more questions about removing data from gun, ping us on Gitter and we'll do our best to help out.

This wiki is where all the GUN website documentation comes from.

You can read it here or on the website, but the website has some special features like rendering some markdown extensions to create interactive coding tutorials.

Please feel free to improve the docs itself, we need contributions!

Clone this wiki locally