How to use the gun.node function in gun

To help you get started, we’ve selected a few gun examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github irislib / iris-lib / src / socialNetwork.js View on Github external
this.gun.user(key).get(`iris`).get(`identitiesBySearchKey`).map().on((id, k) => {
            if (Object.keys(seen).length >= opt.limit) {
              // TODO: turn off .map cb
              return;
            }
            if (!searchTermCheck(key)) { return; }
            const soul = Gun.node.soul(id);
            if (soul && !Object.prototype.hasOwnProperty.call(seen, soul)) {
              seen[soul] = true;
              opt.callback(
                new Contact(this.gun.user(key).get(`iris`).get(`identitiesBySearchKey`).get(k), undefined, this)
              );
            }
          });
        }
github irislib / iris-lib / src / collection.js View on Github external
if (this.serializer) {
      data = this.serializer.serialize(object);
    } if (this.class) {
      data = object.serialize();
    }
    // TODO: optionally use gun hash table
    let node;
    if (opt.id || data.id) {
      node = this.gun.get(this.name).get(`id`).get(opt.id || data.id).put(data); // TODO: use .top()
    } else if (object.getId) {
      node = this.gun.get(this.name).get(`id`).get(object.getId()).put(data);
    } else {
      node = this.gun.get(this.name).get(`id`).set(data);
    }
    this._addToIndexes(data, node);
    return data.id || Gun.node.soul(node) || node._.link;
  }
github irislib / iris-lib / src / collection.js View on Github external
async _addToIndexes(serializedObject, node) {
    if (Gun.node.is(serializedObject)) {
      serializedObject = await serializedObject.open();
    }
    const addToIndex = (indexName, indexKey) => {
      this.gun.get(this.name).get(indexName).get(indexKey).put(node);
    };
    if (this.indexer) {
      const customIndexes = await this.indexer(serializedObject);
      const customIndexKeys = Object.keys(customIndexes);
      for (let i = 0;i < customIndexKeys;i++) {
        const key = customIndexKeys[i];
        addToIndex(key, customIndexes[key]);
      }
    }
    for (let i = 0;i < this.indexes.length; i++) {
      const indexName = this.indexes[i];
      if (Object.prototype.hasOwnProperty.call(serializedObject, indexName)) {

gun

A realtime, decentralized, offline-first, graph data synchronization engine.

(Zlib OR MIT OR Apache-2.0)
Latest version published 22 days ago

Package Health Score

83 / 100
Full package analysis