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

spreadsheet-db-w

v1.0.18

Published

You can use spreadsheets as a convenient database.

Readme

spreadsheet-db-w

A typescript library to use google spreadsheet as a convenient database with type safety.

When use small applications for you or your family, it's a very good way to save data to use google spreadsheet instead of databases.

⚠️Warning⚠️

You need to add "id" column to your all sheets for this library.

Installation

  1. Prepare API key

  2. Create a service account on Google Cloud Platform

  3. Download a service account JSON key

  4. Share your spreadsheet to use as a database with the service account email.

  5. Install this library

npm install spreadsheet-db-w

Easy to use

Things that you have to do to use this library:

  • Prepare API key
  • Create a spreadsheet
  • Create a sheet
  • Add "id" column to your new sheet
  • Initialize authorication class:
const auth = new Authorication({
  private_key: key.private_key,
  client_email: key.client_email
});

Example

import { Authorication, Database, createSchema, number, string, boolean } from "spreadsheet-db-w";
string, boolean } from "./index.js";
import key from "./key.json" with {type: "json"};

const auth = new Authorication({
  private_key: key.private_key,
  client_email: key.client_email
});

// Replace "xxxxxxxxxxxxx" with your spreadsheet id.
// (You can see how to get spreadsheet id below)
const db = new Database("xxxxxxxxxxxxx", auth);

export const booksSchema = createSchema({
  // Keys of this object is ones to access items in source code.
  // Keys of argument must match columns name of your sheet.
  name: string("name"),
  isbn: string("ISBN"),
  price: number("price"),
  bought: boolean("did I buy").optional()
});

export const books = await db.useTable({
  // Replace "0" with your sheet id (The id of the first sheet of spreadsheet is 0).
  // (You can see how to get sheet id below)
  sheetId: 0,
  schema: booksSchema
});

// You don't have to createSchema to create a schema. However the type of variable is suggested if you use it.
export const userSchema = {
  name: string("name"),
  birthday: string("birthday")
};

export const users = await db.useTable({
  // You can use sheet name instead of sheetId
  sheetName: "users",
  schema: userSchema
});



// Get items
const allBooks = await books.getRows();
console.log(allBooks);

// Find item by id
const id1Book = await books.find(1);

// Where
const boughtBooks = await books.where({
  bought: true
});

// Filter items
const inexpensiveBooks = await books.filter((book) => book.price <= 1)
 
// Add a item
const TenBook = await books.appendRow({
  name: "10 Good Ideas to Live Healthy",
  isbn: "00000000",
  price: 0.25,
  bought: true
});

const OneThousandBook = await books.appendRow({
  name: "1000 Good Ideassss to Live Healthy",
  isbn: "00000000",
  price: 30,
  bought: false
});


// Update item by id
await books.updateRow(2, {
  bought: true
});


// Update item by item
OneThousandBook.name = "1000 Good Ideas to Live Healthy";
OneThousandBook.bought = true;
await books.updateRow(OneThousandBook);


// Delete by id
await books.deleteRow(2);

// Delete by item
await books.deleteRow(OneThousandBook);

How to get...

spreadsheet id

  1. Access your spreadsheet to get spreadsheet id
  2. Look at the URL (Your URL is like below:)
https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxx/edit
  1. The spreadsheet id is "xxxxxxxxxxxxx" part in the URL shown above. (It is not always "xxxxxxxxxxxxx".)

sheet id

  1. Access your spreadsheet
  2. Open your sheet to get sheet id
  3. Look at the URL (Your URL is like below:)
https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxx/edit?gid=319982422#gid=319982422
  1. The sheet id is "319982422" in the shown above. (It is not always "319982422".)

(It can be "0" like below URL when the sheet is the firt one in the spreadsheet.)

https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxx/edit?gid=0#gid=0