# GUNJS Database nodes - pre-release, v0.0.4

**URL:** <https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919>\
**Category:** Share Your Nodes\
**Created:** [19 May 2020 12:17 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919 "2020-05-19T12:17:36Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [21 May 2020 15:29 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/21 "2020-05-21T15:29:19Z")

</div>

So does this include a server ? - Can that be a node that binds to the local express service ?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 May 2020 15:36 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/22 "2020-05-21T15:36:42Z")

</div>

Hold yer horses Hoss! No, not yet 😊

This is just the local part. The basic server should be pretty easy as I can take that from the examples on the docs site.

I'll update the thread when things happen.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 May 2020 17:13 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/23 "2020-05-21T17:13:14Z")

</div>

Amazingly, managed to get another update out between dealing with a ransomware & email problem at work!

Refactored the code and settings to make more sense. Also see updated flow and note that the inject with the array JSON doesn't actually update the db. I think it is something to do with the fact that they don't seem to like array's. Will need to add some logic to cater for that. Also some of the labels (actually almost all of them!) are wrong.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/e/1e75a11addd4a9f313779c79132751eb6414b1da.png)

```auto
[{"id":"392af451.27573c","type":"gun-get","z":"908cedac.17439","name":"","gunconfig":"dbbc7abe.617de8","soul":"test3","x":180,"y":360,"wires":[["462a3caf.4daf54"]]},{"id":"462a3caf.4daf54","type":"debug","z":"908cedac.17439","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":490,"y":360,"wires":[]},{"id":"a883018d.a7203","type":"gun-set","z":"908cedac.17439","name":"","gunconfig":"dbbc7abe.617de8","soul":"test3","x":470,"y":420,"wires":[["d9652d9e.74b47"]]},{"id":"d9652d9e.74b47","type":"debug","z":"908cedac.17439","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":420,"wires":[]},{"id":"d80d1361.42b9a","type":"inject","z":"908cedac.17439","name":"","topic":"","payload":"[1,2,3]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":420,"wires":[["a883018d.a7203"]]},{"id":"4644c454.96e8ac","type":"inject","z":"908cedac.17439","name":"","topic":"","payload":"{\"one\":1,\"two\":2}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":500,"wires":[["a883018d.a7203"]]},{"id":"2054570f.b77cb8","type":"inject","z":"908cedac.17439","name":"","topic":"","payload":"Just some text","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":460,"wires":[["a883018d.a7203"]]},{"id":"dbbc7abe.617de8","type":"gun-config","z":"","server":""}]

```

Also @dceejay, I think that Gun.js sets itself up as a peer automatically. If you check the log, you will see that it reports that it is multicasting on 233.255.255.255:8765 or some such.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [21 May 2020 18:24 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/24 "2020-05-21T18:24:19Z")

</div>

Nice work. interested to see where this goes. I was tempted to pick this up if no one took the bait (fortunately you did). I might load it up and get a feel for it - see what it might be useful for - maybe I can throw in some ideas (or spanners)?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [21 May 2020 21:28 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/25 "2020-05-21T21:28:05Z")

</div>

So it is - wowser it does seem quite "chatty" on that multicast. So I guess it tries to do local syncing automatically. Hopefully you can specify a list of remote servers to sync to for all those out fo the local network... (and indeed turn off local multicast). No doubt we will find out ! Looks good so far.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 May 2020 22:00 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/26 "2020-05-21T22:00:03Z")

</div>

> [@dceejay](#):
>
> wowser it does seem quite "chatty" on that multicast

Seems rather chatty on the log too ☹ Might raise an issue on that to see if we can get an option to turn off the silly startup log msg.

> [@dceejay](#):
>
> Hopefully you can specify a list of remote servers to sync

Well, you can now enter 1 anyway, I've not yet made it a list and it is currently entirely untested so please feel free 😉 you set it using the config node.

> [@Steve-Mcl](#):
>
> Nice work. interested to see where this goes. I was tempted to pick this up if no one took the bait

Thanks. I nearly didn't and I really shouldn't have - but hey, who can resist right!

> [@Steve-Mcl](#):
>
> I might load it up and get a feel for it

Well now would be a good time.

> [@Steve-Mcl](#):
>
> maybe I can throw in some ideas (or spanners)?

Please do, Gun.js is quite complex in detail and not especially well documented. However, it looks like it might be really quite useful. At the moment, this is just a very simplistic proof of concept and there are a lot of options that need adding.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 May 2020 22:08 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/27 "2020-05-21T22:08:33Z")

</div>

OK, enough for 1 day. Please see the latest update - I'm trying to remember to increment the dev release numbers as I go along to make it a bit easier to know when there is an update.

The final version for today gets a couple of additional nodes - hopefully reasonably obvious in use. However, I'm finding that there are a lot of subtleties to Gun.js that are not yet reflected in the code. Also, you can currently only add/retrieve top-level entities to a "soul" at the moment and that itself has some complexities. I've started to try and document these either in the code or in the test flow shared below.

_I am particularly interested, now that we have a very basic working proof-of-concept, in your opinions on style (of use not visual style) and vision._

You must have v0.0.1-dev4 installed for this flow.

```auto
[{"id":"8c238839.7283e8","type":"tab","label":"Gun.js Tests","disabled":false,"info":""},{"id":"674ccc55.7b53d4","type":"gun-get","z":"8c238839.7283e8","name":"","gunconfig":"dbbc7abe.617de8","soul":"test3","x":120,"y":140,"wires":[["4e9892bc.55e42c"]]},{"id":"4e9892bc.55e42c","type":"debug","z":"8c238839.7283e8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":140,"wires":[]},{"id":"c9faf3c0.9378b","type":"gun-set","z":"8c238839.7283e8","name":"","gunconfig":"dbbc7abe.617de8","soul":"test3","x":410,"y":320,"wires":[["e850514.bfcacb"]]},{"id":"e850514.bfcacb","type":"debug","z":"8c238839.7283e8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":320,"wires":[]},{"id":"c046700e.b3845","type":"inject","z":"8c238839.7283e8","name":"","topic":"","payload":"[1,2,3]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":320,"wires":[["c9faf3c0.9378b"]]},{"id":"29f88dcf.4d4672","type":"inject","z":"8c238839.7283e8","name":"","topic":"","payload":"{\"one\":10,\"two\":20}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":400,"wires":[["c9faf3c0.9378b"]]},{"id":"69e1e701.54fa38","type":"inject","z":"8c238839.7283e8","name":"","topic":"","payload":"Just some text","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":360,"wires":[["c9faf3c0.9378b"]]},{"id":"956f71ab.57077","type":"gun-put","z":"8c238839.7283e8","name":"","gunconfig":"dbbc7abe.617de8","soul":"test3","x":410,"y":480,"wires":[["3e00e185.de11ae"]]},{"id":"3e00e185.de11ae","type":"debug","z":"8c238839.7283e8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":480,"wires":[]},{"id":"95694e7c.77ae8","type":"inject","z":"8c238839.7283e8","name":"","topic":"","payload":"[1,2,3]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":480,"wires":[["956f71ab.57077"]]},{"id":"3d410b2d.14a174","type":"inject","z":"8c238839.7283e8","name":"","topic":"","payload":"{\"one\":1,\"two\":2}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":560,"wires":[["956f71ab.57077"]]},{"id":"88515841.6a40b8","type":"inject","z":"8c238839.7283e8","name":"","topic":"","payload":"Just some text","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":520,"wires":[["956f71ab.57077"]]},{"id":"23b6eb2e.2a0ee4","type":"gun-get-once","z":"8c238839.7283e8","name":"","gunconfig":"dbbc7abe.617de8","soul":"test3","singleOut":true,"x":400,"y":220,"wires":[["765375bb.f2d2dc"]]},{"id":"765375bb.f2d2dc","type":"debug","z":"8c238839.7283e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":220,"wires":[]},{"id":"fcbd3552.b44518","type":"inject","z":"8c238839.7283e8","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":95,"y":220,"wires":[["23b6eb2e.2a0ee4"]],"l":false},{"id":"32811971.abb886","type":"comment","z":"8c238839.7283e8","name":"Set vs Put","info":"On a root/top-level document:\n\n* Set with an object creates a single document with 2 properties and random key - Put creates two documents with keys of the object top-level property names.\n\n* Put with a scalar will not do anything because no key is available. Set does work because it creates a random key.","x":440,"y":400,"wires":[]},{"id":"216039df.978596","type":"comment","z":"8c238839.7283e8","name":"TODO","info":"* use .off() to stop this from creating a listener and only get triggered on input.","x":190,"y":200,"wires":[]},{"id":"efac55f8.ab4cf8","type":"comment","z":"8c238839.7283e8","name":"TODO","info":"","x":230,"y":120,"wires":[]},{"id":"75041178.1b3","type":"comment","z":"8c238839.7283e8","name":"Info","info":"## Using `.on` instead of `.map.on`\n\n* returns a SINGLE record for the soul instead of 1 for each document.\n* Does NOT output anything when a document is added/changed because the whole soul would need to be changed to trigger an update.","x":570,"y":200,"wires":[]},{"id":"abd816af.1d08f8","type":"comment","z":"8c238839.7283e8","name":"Overall TODO","info":"* Enable inner changes/subscriptions instead of just the soul-level.","x":470,"y":60,"wires":[]},{"id":"dbbc7abe.617de8","type":"gun-config","z":"","server":""}]

```

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 May 2020 22:09 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/28 "2020-05-21T22:09:47Z")

</div>

> [@Steve-Mcl](#):
>
> I was tempted to pick this up if no one took the bait

By the way, if you want to collaborate on this, please shout. Plenty of coding to go round 🙂

Same goes for other people.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [22 May 2020 13:00 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/29 "2020-05-22T13:00:27Z")

</div>

@TotallyInformation - so i had a bit play...

### node-red 1 (localhost:1880)

![JGtt5dEw7W](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/7/b7114bc9e320d75a71c5df0deb9bc5f4ae6f9e00.gif)

### node-red 2 (localhost:1881)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/1/e1f2c3fa42b9a8e1b64aa6dd5c4bdfff2574cdf3.png)

works quite well - minimal setup - really simple to get going locally. 👍

### Initial thoughts (some are lack of gun knowledge, some are observations I'm certain will get resolved as it matures)...

- the config node shows ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/5/d5725ce8edd41f503d0f5c888d937a009e79b52d.png) when Gun.js peer server is left blank
- what is the difference between put and set?
  - I did note PUT did not cause the GET to trigger

- does the GET node need an input and a means of querying? (not certain it it works that way? - I did try in a node console (as described [here](https://gun.eco/docs/API#get)) but `gun.get("soul1-out").val()` just complained `Uncaught TypeError: Gun.log.once is not a function`
- do the PUT and SET need to be 2 separate nodes?
  - if the gun node permitted an option of PUT / GET then this could be determined at runtime by a msg property (e.g. `msg.gunOp = "PUT"`) (Again, might not make sense when i understand the difference - time to go reading i suspect)

- have you setup a Gun.js peer server yet? How did you do that? Do you see a "Gun.js peer" node being added in this package - permitting a user to run a peer server from node-red?

Final words

- gonna do some local MQTT performance testing as comparison. Perhaps send different data and larger sizes too (and perhaps run it in a loop for average, min and max timing)

EDIT - vs MQTT (simple test)

 ![rwKZl5Ygir](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/c/1c466966eb99f869e621c59e9a148f249d02020f.gif)

EDIT - 20kb string  
I observed GUN being about 1/2 the speed of my local aedes MQTT broker...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/c/ecb8c1b2dec3c51b471f7d4641d568c3b8c51ff3.png)  
... while this is my 2 NR servers (on one machine, interanal data only) - perhaps when externalised with many clients, GUN will prove superior?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [22 May 2020 14:40 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/30 "2020-05-22T14:40:58Z")

</div>

Thanks Steve, interesting stuff.

> [@Steve-Mcl](#):
>
> the config node shows ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/5/d5725ce8edd41f503d0f5c888d937a009e79b52d.png) when Gun.js peer server is left blank

Ah, knew there was something else to fix there - thanks I'll hit that one, should be blank and shouldn't say GET.

> [@Steve-Mcl](#):
>
> difference between put and set

Did you load up the test flow? It has a brief explanation there. Not sure I fully understand it myself yet.

> On a root/top-level document:
> 
> - Set with an object (of 2 props) creates a single document with 2 properties and random key - Put creates two documents with keys of the object top-level property names.
> - Put with a scalar will not do anything because no key is available. Set does work because it creates a random key.

> [@Steve-Mcl](#):
>
> does the GET node need an input and a means of querying?

Not really sure what to call that node really. Started with GET but it is more of an "In" node like MQTT-IN, it is a subscription to changes on the soul and any of its hierarchy. Ultimately, I'll add something that lets you create a subscription on something further down a hierarchy. Probably using a simple dotted notation.

> [@Steve-Mcl](#):
>
> I did try in a node console

You would have to load Gun in a browser context for that. Also, don't forget that get() returns a Gun object which has a number of methods but that doesn't include `val()` - if that came from the video, I note that some of those seem to be well out of date - seems that Gun has moved fast. You need an `.once()` with a callback or a `.map().once()` (or on()) if you want separate outputs for each change.

> [@Steve-Mcl](#):
>
> do the PUT and SET need to be 2 separate nodes

Maybe not, perhaps a single node with an option to use one or the other would be better? The structure of the processing and settings is otherwise identical.

> [@Steve-Mcl](#):
>
> have you setup a Gun.js peer server yet?

No. I'm thinking that another node will be needed for that.

However, note that Gun on its own _does_ create a streaming multicast server. Have a look at your node-red startup log and you will see something like `Multicast on 233.255.255.255:8765`.

Of course, that is a randomly assigned port. So not terribly useful. But you can use it for testing - but then you know that as you've done it!

> [@Steve-Mcl](#):
>
> Do you see a "Gun.js peer" node being added in this package - permitting a user to run a peer server from node-red?

Absolutely. This should be easy to do in Node-RED since ExpressJS is already available. I'll probably use the existing user-facing ExpressJS server that is already used by the http, Dashboard and uibuilder nodes. Might add an option for a separate server later on in case you wanted to use separate security settings.

> [@Steve-Mcl](#):
>
> perhaps when externalised with many clients, GUN will prove superior?

Hmm, interesting. I think that this probably relates to the "eventual sync" model that it uses. Something that is much harder (if indeed possible) to get right with MQTT. Also, the fact that you can update a single property deep in the hierarchy most likely will show big differences - Gun gives you a LOT more flexibility than MQTT.

So I'm not sure that server-to-server performance is really the right measure. Raw read and write performance is more likely to be interesting.

I'm also interested in the performance once your Gun datastore gets really big. Gun is really more comparable with MongoDB or CouchDB. But remember, the focus for Gun is on being a local store with sync and no need for a central db server.

There appears to be a lot of (hidden) subtlety in Gun that needs some detailed discovery.

Now that I've discovered some basics, I'm quite keen to have a go at building a Node-RED context store with it. I think it is a much better fit than other versions I've looked at. Imagine an offline capable context store that you can share between Node-RED instances - across the globe if you wanted to!

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [22 May 2020 15:01 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/31 "2020-05-22T15:01:58Z")

</div>

> [@TotallyInformation](#):
>
> Of course, that is a randomly assigned port

well no - they have assigned it to themselves - it's the same for all instances. - If I had another instance running locally I would expect them to talk automatically - (assuming no firewalls... bit of an assumption)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [22 May 2020 15:03 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/32 "2020-05-22T15:03:07Z")

</div>

> [@TotallyInformation](#):
>
> Now that I've discovered some basics, I'm quite keen to have a go at building a Node-RED context store with it. I think it is a much better fit than other versions I've looked at. Imagine an offline capable context store that you can share between Node-RED instances - across the globe if you wanted to!

That does sound interesting

> [@TotallyInformation](#):
>
> You would have to load Gun in a browser context for that. Also, don't forget that get() returns a Gun object which has a number of methods but that doesn't include `val()` - if that came from the video, I note that some of those seem to be well out of date - seems that Gun has moved fast. You need an `.once()` with a callback or a `.map().once()` (or on()) if you want separate outputs for each change.

I followed the online documentation, which linked to a video so yeah I tried the `.val()` as described.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [22 May 2020 15:03 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/33 "2020-05-22T15:03:20Z")

</div>

Ah, OK, I thought I had seen it change. My bad.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [22 May 2020 15:06 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/34 "2020-05-22T15:06:00Z")

</div>

> [@Steve-Mcl](#):
>
> That does sound interesting

I guess I know what I'll be doing this weekend then - dependent on what Mrs K wants done 😇 🌱 🌿

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [22 May 2020 15:17 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/35 "2020-05-22T15:17:44Z")

</div>

Well - mine is the same :-), And indeed just running it up on another Pi - If I do the object PUT then two objects turn up on both GET(test3) nodes... neither the array nor simple text go anywhere.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [22 May 2020 19:49 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/36 "2020-05-22T19:49:12Z")

</div>

Right, so learned a little more.

There appears to be no way to actually delete a top-level element! The best you can do is set it to `null`. This appears to be a "feature" though it seems very odd to me.

The trick appears to be to move everything down a level and treat the top level like a db (that you can't fully delete!). You can empty a top level object by putting 'null' to it. That will remove any lower level elements.

So back to plan A where the config node included what I'd been calling the "soul". In truth, the concept of a soul is also more subtle than I'd thought. So I plan to call the top level a "db" and so you will be able to create multiple db's using config nodes. Unless anyone else has a better plan?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [22 May 2020 21:40 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/37 "2020-05-22T21:40:52Z")

</div>

hmm - not so obvious is it :-)... so test3 (in your previous flows) seems to be the "database".  
If I'm talking old school then we would then typically use something like msg.topic as the key and the payload as whatever, and put anything without a topic under some "unknown" key. So then hopefully you could "subscribe" to topics etc... in the familiar way... (though I haven't seen anything about wild cards - but I guess you can get things per property level ? needs more digging 🙂

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [22 May 2020 22:46 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/38 "2020-05-22T22:46:37Z")

</div>

No, not at all obvious. But I think you are about right. Looks like you may be able to use forward-slashes as delimiters too similar to MQTT topics. No wild cards or anything like that.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [23 May 2020 07:28 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/39 "2020-05-23T07:28:59Z")

</div>

The 'soul' concept confuses me a bit. It is a graph database with a top element in which related elements live.  
'database' (or graph) as top element makes more sense to me.

Looking at their api, it is heavily based on chaining. The GET method is used to PUT elements/objects in relation to the element specified in the GET. The current PUT node allows for one of those elements. This should be more generalized using a PUT input property I think. The SET method is used to create groups (i read that as a related table name) - like a (root?) topic in MQTT world ?

In their examples I see:

```auto
gun.get('user/marknadal').get('wife').get('husband').get('name').once( 
  (name) => console.log( 'Marks wife husbands name is '+name)
)

```

This is quite cool, but how would it translate into a flow ?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [23 May 2020 09:12 UTC](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919/40 "2020-05-23T09:12:24Z")

</div>

Yes - I saw that ... and indeed it may not translate brilliantly... - but hey - if we can get 80% of the effect with just single get and set - and then just chain up nodes... - not as efficient - but.  
Or maybe (for now) just accept it - and use it as a cool object store with replication and subscriptions. 2/3 isn't bad.  
There can always be version 2.

[Previous page](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919.md?page=1)

[Next page](https://discourse.nodered.org/t/gunjs-database-nodes-pre-release-v0-0-4/26919.md?page=3)
