Google Sheets As Your Databaseby@jsborked
13,158 reads

Google Sheets As Your Database

Read on Terminal Reader

Too Long; Didn't Read

Company Mentioned

Mention Thumbnail
featured image - Google Sheets As Your Database
Just Chris HackerNoon profile picture


Just Chris
react to story with heart

Very rapid prototyping is helpful for trying out your brainstormed ideas while they are still fresh in your mind, without the need for a lot of setup. New tools are emerging which enable you to rapid try out new ideas at the client, server, and database layers.

Tools like GoMix and RunKit can be very helpful in getting your server-side code running quickly, and being able to test out changes on the fly.

In the database layer, a “database” that can be easily edited and used by a server application can be established in minutes using Google Sheets.

In this example, I’ll read from a published Google Sheet. If I need to make changes to the data, I’ll just make them directly in the sheet, so there’s no need to learn a framework. I use gsheet-web for this purpose, which is available on NPM.

Here’s the database. A published public sheet that can be used to store the data.

Example Public Spreadsheet_Class Data Student Name, Gender, Class Level, Home State, Major, Extracurricular Activity Alexandra, Female, 4. Senior…

Reading the sheet data, using the id of the sheet, is very simple.

var gsheet = require('gsheet-web');

gsheet('1KPJr7wBEzicgrqukhEZBdGCqNQQB-ldrRrS0lxmq_qo', (data)=>{console.log('Try callback ', data.length); // array of objects});

In this case, Gsheet-web will read the sheet as an array of objects. Available for your app to use. In this example, since we are not writing to the sheet from the app, there is no authentication required.

Here’s an example of server-side code accessing this data, on RunKit.

RunKit_RunKit notebooks are interactive javascript playgrounds connected to a complete node environment right in your browser…

It also works with Promises, so will be “async/await ready”. To use the promises interface, simply use:

gsheet('1KPJr7wBEzicgrqukhEZBdGCqNQQB-ldrRrS0lxmq_qo').then((data)=>{console.log('Try promise ', data.length);});

There are other modules out there that will assist in using G-Sheets data as your database, and dropping these into your prototypes is a fast way to get a database layer up and running without database setup.


. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa