Feasibilities of Google Sheets that make it a good basic DatabaseÂ
# Features that make it a good database
Google Sheets
Store Data in Rows and columns
# Google API's
Google Api's for Sheets
Get
Functionalities
Obstacles
Lack of params for different CRUD Operations
# Idea
Idea: Build a ORM for Gsheets support using google API's as a dependency
Source of Motivations:
- Lack of a updated ORM with proper documentation.
 The only one that exists (https://github.com/mickhansen/google-sheets-orm) doesn't have a documentation so very difficult to use.
Â
- Easy and fast setup
 : Setting up Google sheets thorugh Google Console Portal is so easy and fast to setup for quick running of a database service.
Â
- Best Platform for non-tech people
 : Google Sheets can be a best platform non-technical people and the sheet can also be integrated to SQL databases like Postgres using tools like https://www.wax.run/
# PRESENTING CODE
Implementation in Javascript
const {google} = require("googleapis");
const keys = require("/keys.json");
const cl = new google.auth.JWT(keys.client_email, null, keys.private_key, [
"https://www.googleapis.com/auth/spreadsheets",
]);
class Sheet {
constructor(sheetId, sheetName) {
this.sheetId = sheetId;
this.sheetName = sheetName;
}
// find function to GET all Cells
async find() {
try {
const gsapi = google.sheets({version: "v4", auth: cl});
const opt = {
spreadsheetId: this.sheetId,
range: this.sheetName,
};
// Get all rows in the sheet. This response is a array of arrays
let rows = await gsapi.spreadsheets.values.get(opt).data.rows;
const response = [];
// converting array format to json with first row as key.
for (let row_id = 1; row_id < rows.length; row_id++) {
let row = rows[row_id];
let obj = {};
for (const heading in rows[0]) {
obj[rows[0][heading]] = row[heading];
}
response.push(obj);
}
return response;
} catch (err) {
throw new Error("No such Sheet found");
}
}
}
const data_instance=new Sheet(env.SheetID,env.Sheetname)
const all_data=data_instance.find();
Add batch Update for all featuresÂ
Timeline
- Rajiv Harlalka
- github.com/rajivharlalka
- rajivharlalaka.me
Â