Search code examples
gun

Getting full path to an updated properties


Node.js to Node.js, no browser, gun 0.8.7

Is there a way to be notified about a full path to an updated property in gun?

For, example, my listener

gun.get('task/123').map().on(function (t) {
  console.log(t);
});

fires the following update

{ _:
   { '#': 'j8pwhxy6Z121xeEvWjJk',
     '>': { num: 1507901726322, force: 1507901726322 } },
  num: 104,
  force: 23 }

Both of these properties are 2nd level properties behind stat property

{
  stat: {
    num: 104,
    force: 23
  }
} 

I want to know what property these properties behind and a name of the node, for example task/123.


Solution

  • function setupMap() {
      var path='task/123';
      gun.get(path).map().on(function (val,field) {
        console.log( path, field,'=',val );
       });
    }
    

    -or- This will return more direct values....

    function setupMap() {
      var path='task/123';
      gun.get(path).map().map().on(function (val,field) {
        console.log( path, field,'=',val );
       });
    }
    

    -or-

    function setupMap() {
      var path='task/123';
      gun.get(path).map().on(function (val,field) {
        console.log( this.back(-1)._['#'], field,'=',val );
       });
    }