gsheets-db.js is a lightweight and fast wrapper for using Google Sheets as a database in your Node.js projects. Built with TypeScript for maximum type-safety and full Intellisense support (Not official Google NPM package!).
You can install the library via NPM:
npm install gsheets-db.js
Before using the library, ensure you have a creds.json file from a Google Cloud Service Account.
import { SheetsDB } from "gsheets-db.js";
import creds from "./creds.json" with { type: "json" };
// Configure the database.
const usersDB = new SheetsDB({
credentials: { clientEmail: creds.client_email, privateKey: creds.private_key },
sheetName: "users",
// sheetNamt is the sheet in the spreadsheet.
spreadsheetId: "spreadsheet id, can be found by the url of the spreadsheet",
schema: ["id", "name", "email"]
});
// Initialize the database
await usersDB.init();
// Get all the data in the table
const all = await usersDB.getAll();
console.log(all);
The full documentation is available at: https://yossi-batash.github.io/gsheets-db.js/
Distributed under the ISC License. See LICENSE for more information.
Developed with ❤️ by Yossi Batash