Decentralized Database Mastery: A Unified Guide from Basics to Advanced with gunDB

Gustav Corpas
21 min readJan 7, 2024

TLDR;

This introduces the reader to gun by starting with a super basic example and then making that same example increasingly more complex. We’ll cover certificates, database design principles, iteration, awaiting values and much more.

// We start here
const alice = gun.get("members").get("alice");
alice.get("name").put("alice");

// We end here
const user_name = await User.name.chain;
Group.members.iterate(member => {
member.name.chain.put(user_name, certificate);
}

TIP: If you have read this article before or are familiar with gun, there is a section titled Putting it all together at the end that encapsulates all the concepts of the article…

Introduction

2024 just started (well.. when I began this article it did :), and that made me reflect a bit on what I did in 2023 as a developer. The most impactful thing for me, was learning about gunDB. It is a local, offline-first database that makes it so amazingly easy to create peer to peer applications.

For me, working with and setting up databases has always been this somewhat unpleasant development experience, especially if you just need something that’s quick and dirty — for a small side project.

--

--

Gustav Corpas

I write about technology and society. Or anything that is interesting to me.