1. The example you have is only for local lan... or automatically if PnP Router... finding nodes in the world and cloning db ? (or parts of it)...
I excluded the NodeJS part in the example because I didnt want to create confusion. You can create as many nodes as you want and add them to the project using .
AddPeer.
The data you write to the db & read will first be written to IndexedDB, in case a peer gets disconnected / becomes unavailable. As soon as a peer is online, your data will be synced to the other peers,
provided they are subscribed to it.
Also, if you are subscribed to content that is "stored" in another peer, it will be synced with your IndexedDB to be available for you. To avoid loading everything at ones, the subscription model is used. Thus the cloning will be on everything you want to "watch".
2. I understand that you can "clone-share" the db ofcourse to all nodes in the world but when having special user-permissions those data kept encrypted and not shared - right ?
Yes. There are 3 sets of data storage, 2.1 public, 2.2 user and 2.3 frozen.
2.1 Content in public is accessible to everyone. They can read & write & delete it
2.2 User is available to everyone but people cannot write / delete it, only the user can. This content can be encrypted by the user and secrets shared between people who will have access to it. The public who sees the content sees is as encrypted data. In the example, I added Email, First and LastName in the "profile" collection of the user. Only the logged user has access to that information for write/delete. Others can see it but wont. If I wanted that data to be encrypted, then I will add that for reading & writing.
2.3 Frozen space is basically that, frozen. You write to it using a hash and no one can do anything to it.
3. If not sharing to all nodes... targetting any Central or Many Index Node that you can have ? and what step of tutorial is that ?
Yes you can. This is a key-value store database afterall. You can use if for anything actually. They just don't recommend banking apps for it. I will be making a CRUD example soon also including a chat app in the future.
4. Relaying to others.
You need a relay peer server to do this otherwise content will not be relayed to others on the network. Perhaps I can get lucky deploying the NodeJS code somewhere to explore this.
You can also find details about gunDB from their site,
https://gun.eco/