Let me suggest an effective way to make a small project without a real database.

Edouard CLAUDE
Apr 17 · 2 min read

In most cases, database usage and their infrastructure is essential when talking about the web project. However sometimes you want to realize a cheap project without deploying a big mechanic. In this publication I will show you how I make small free databases with Google Sheets.


❌ Draft — Writing in progress please do not use this document in a real project ❌


1. Google Sheets Setup

Go to Google Sheet to create a new blank document. We use pages here as database tables. In our example here is what the document looks like :

The three pages represent the “tables”, we use here the upper left corner to enter the data and for the names of colones use simple names to identify without ambiguous characters.

Then you have to make your file public for reading then publish it on the web (File/Publish on the web)


2. Clone initial sources

GithHub : https://github.com/madara-io/reactjs-context-google-sheets

yarn install

Folders

.
├── README.md
├── package.json
├── public
│ ├── favicon.ico
│ ├── index.html
│ └── manifest.json
├── src
│ ├── Components
│ │ ├── Footer.js
│ │ ├── NavElem.js
│ │ ├── Post.js
│ │ └── Title.js
│ ├── Containers
│ │ ├── Layout.js
│ │ └── NavBar.js
│ ├── Contexts
│ │ └── AppContext.js
│ ├── Routes
│ │ └── Router.js
│ ├── Screens
│ │ ├── Blog.js
│ │ ├── Home.js
│ │ └── Skills.js
│ ├── Utils
│ │ └── sheetsDB.js
│ ├── index.js
│ └── serviceWorker.js
└── yarn.lock

Brief explanation of the tree:

  • Components: Reusable elements
  • Containers: Elements with children (like Layout)
  • Contexts: Data dispatcher
  • Routes: Urls list
  • Screens: Pages include Containers and Components
  • Utils: Toolbox

For play with Google Sheets we need to create custom function :

./src/Utils/sheetsDB.js

sheetsToArray() convert this

[...][{"scheme":"http://schemas.google.com/spreadsheets/2006","term":"http://schemas.google.com/spreadsheets/2006#list"}],"title":{"type":"text","$t":"Home"},"content":{"type":"text","$t":"name: home, link: /"},"link":[{"rel":"self","type":"application/atom+xml","href":"https://spreadsheets.google.com/feeds/list/1flaobRnapU9AouMptxcpCw9QEmGl-PjDRXSbZc4FOm4/1/public/values/cokwr"}],"gsx$title":{"$t":"Home"},"gsx$name":{"$t":"home"},"gsx$link":{"$t":"/"}},{"id":{"$t":"https://spreadsheets.google.com/feeds/list/1flaobRnapU9AouMptxcpCw9QEmGl-PjDRXSbZc4FOm4/1/public/values/cpzh4"},"updated":{"$t":"2019-04-17T03:29:19.013Z"},"category":[{"scheme":"http://schemas.google.com/spreadsheets/2006","term":"http://schemas.google.com/spreadsheets/2006#list"}],"title":{"type":"text","$t":"Blog"},"content":{"type":"text","$t":"name: blog, link: /blog"},"link":[{"rel":"self","type":"application/atom+xml","href":"https://spreadsheets.google.com/feeds/list/1flaobRnapU9AouMptxcpCw9QEmGl-PjDRXSbZc4FOm4/1/public/values/cpzh4"}],"gsx$title":{"$t":"Blog"},"gsx$name":{"$t":"blog"},"gsx$link":{"$t":"/blog"}},{"id":{"$t":"https://spreadsheets.google.com/feeds/list/1flaobRnapU9AouMptxcpCw9QEmGl-PjDRXSbZc4FOm4/1/public/values/cre1l"},"updated":{"$t":"2019-04-17T03:29:19.013Z"},"category":[{"scheme":"http://schemas.google.com/spreadsheets/2006","term":"http://schemas.google.com/spreadsheets/2006#list"}],"title":{"type":"text","$t":"Skills"},"content":{"type":"text","$t":"name: skills, link: /skills"},"link":[{"rel":"self","type":"application/atom+xml","href":"https://spreadsheets.google.com/feeds/list/1flaobRnapU9AouMptxcpCw9QEmGl-PjDRXSbZc4FOm4/1/public/values/cre1l"}],"gsx$title":{"$t":"Skills"},"gsx$name":{"$t":"skills"},"gsx$link":{"$t":"/skills"}}]}}

to this

0: {title: “Home”, name: “home”, link: “/”}
1: {title: “Blog”, name: “blog”, link: “/blog”}
2: {title: “Skills”, name: “skills”, link: “/skills”}

It is more pleasant to handle you will agree

Edouard CLAUDE

Written by

Cofounder CTO of MADARA https://www.madara.io

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade