1.0.1 • Published 1 year ago
@zachsents/sheets-db v1.0.1
SheetsDB
A package that lets you use Google Sheets as a super basic database. It's probably more of a store than a database.
Usage
import { Database, QueryOperators } from "@zachsents/sheets-db"
// Create database instance
const db = new Database(SPREADSHEET_ID, {
serviceAccountKeyPath: "./path/to/service_account_key.json",
})
// Load existing tables & key-value stores
await db.initialize()
// Get table by name -- in Google Sheets, the sheet should be called "tbl_Users"
const usersTable = db.getTable("Users")
// Add a row to the table
await usersTable.addRow({
name: "Zach",
age: 23,
})
// Query the table
const rows = await usersTable.queryRows([
{ field: "name", operator: QueryOperators.Equals("Zach") }
])