Search code examples
javascriptgun

gun.not() method does not work with nested nodes


How to make gun.not() to work with nested nodes?

Do we have any other technique to init a nested node?

The .not() method works if I deal with root level nodes. But in case of a nested node, I just get undefined when I want to get the node values.

var gun = new Gun();
var app = gun.get('app');
var demo = document.getElementById('demo');

deleteDino('dino/velociraptor');
initDino('dino/velociraptor');

app.get('dino/velociraptor').get('statistics').val(function(value) {
  console.log('value', value);
  demo.innerHTML = JSON.stringify(value);
});

function deleteDino (name) {
  app.get(name).put(null);
}

function initDino (name) {
  app.get(name).not(function () {
    app.get(name).put({
    	statistics: {
      	force: 5,
        speed: 17,
        intelligence: 23
      }
    });
  });
}
<script src="https://rawgit.com/amark/gun/master/gun.js"></script>
<script src="https://rawgit.com/amark/gun/master/lib/not.js"></script>
<p id="demo"></p>


Solution

  • Works as expected.

    putting 'null' into the dino name means it exists. Not tests for existance, not blankness.