npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

googlesheet-litedb

v0.0.4

Published

A lightweight database implementation using Google Sheets as storage

Readme

googlesheet-litedb

A lightweight TypeScript library that turns Google Sheets into a simple database with CRUD operations. Perfect for prototypes, small applications, or when you need a simple, visual data store that non-technical users can also access.

Features

  • 🔄 Simple CRUD operations (Insert or Update by Batch, Find All, Delete with id by Batch)
  • 📊 Uses Google Sheets as a database backend
  • 🚀 Type-safe with TypeScript
  • 🎯 Automatic type conversion for common data types
  • ⚡ Built-in caching for better performance
  • 📝 Simple API for data operations

Installation

npm install googlesheet-litedb googleapis
# or
yarn add googlesheet-litedb googleapis
# or
bun add googlesheet-litedb googleapis

Prerequisites for this example

  1. Set up a Google Cloud Project
  2. Enable the Google Sheets API
  3. Create service account credentials
  4. Share your Google Sheet with the service account email
gcloud auth login

gcloud config set project YOUR_PROJECT_ID

gcloud services enable sheets.googleapis.com

gcloud auth application-default login --scopes=https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/drive,https://www.googleapis.com/auth/spreadsheets

Usage

Basic Example

import { google } from 'googleapis';
import type { Auth } from 'googleapis';
import { createSheetsRepository } from 'googlesheet-litedb';
import type { Logger, TableConfig } from 'googlesheet-litedb';

/********************
 * Configure library
 ********************/

// Define your data structure
type User = {
  id: string;
  name: string;
  email: string;
  numberOfChildren: number;
  createdAt: Date;
};

// Configure your table
const userTableConfig: TableConfig = {
  spreadsheetId: 'YOUR_SPREADSHEET_ID',
  sheetName: 'Users',
  firstColumnIdConfig: { attributeName: 'id', type: 'string' }, // should be the first column of your table
  columns: [ // other columns of your table in the order in the sheet
    { attributeName: 'name', type: 'string' },
    { attributeName: 'email', type: 'string' },
    { attributeName: 'numberOfChildren', type: 'number' },
    { attributeName: 'createdAt', type: 'date' },
  ],
};

// Initialize Google Sheets client
const auth = new GoogleAuth({scopes: ['https://www.googleapis.com/auth/spreadsheets','https://www.googleapis.com/auth/drive.file']});
  const authClient = await auth.getClient();
  const sheetsClient = google.sheets({ version: 'v4', auth: authClient as Auth.BaseExternalAccountClient });

/********************
 * Use the library
 ********************/

// Create repository
const userRepository = await createSheetsRepository<User>(
  sheets,
  userTableConfig,
  5 * 60 * 1000 // cache duration in milliseconds, default value is 5 minutes (argument is optional)
);

// Use the repository
// Insert or update users
await userRepository.insertOrUpdate([
  {
    id: '1',
    name: 'John Doe',
    email: '[email protected]',
    numberOfChildren: 2,
    createdAt: new Date(),
  },
]);

// Find all users
const users = await userRepository.findAll();

// Delete users
await userRepository.deleteByIds(['1']);

Supported Data Types

  • string
  • number
  • date
  • boolean
  • array
  • object

Configuration

TableConfig Interface

type TableConfig = {
  spreadsheetId: string;
  sheetName: string;
  firstColumnIdConfig: {
    attributeName: string;
    type: 'string';
  };
  columns: {
    attributeName: string;
    type: 'string' | 'number' | 'date' | 'boolean' | 'array' | 'object';
  }[];
};

Cache Configuration

The library includes built-in caching to improve performance. By default, cache expires after 5 minutes. You can customize this when creating the repository.

Best Practices

  1. Always use the first column as the ID column
  2. Keep your sheet structure simple and flat
  3. Use appropriate data types for your columns

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.