# @404invalid-user/googlesheetsdb

> get and add data to google sheets easily using objects

Latest version **3.0.0** (published 2026-05-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install @404invalid-user/googlesheetsdb
pnpm add @404invalid-user/googlesheetsdb
yarn add @404invalid-user/googlesheetsdb
bun add @404invalid-user/googlesheetsdb
```

## Health

**Score 50/100 (C)** — status: active.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2026-05-31 |
| First published | 2022-03-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | 404invalid-user |
| Maintainers | 404invalid-user |
| Keywords | googleapis, mongoose, googlesheets |

## Links

- npm: https://www.npmjs.com/package/@404invalid-user/googlesheetsdb
- Repository: https://github.com/404invalid-user/googlesheetsdb
- Homepage: https://github.com/404invalid-user/googlesheetsdb#readme
- Issues: https://github.com/404invalid-user/googlesheetsdb/issues
- npm.io page: https://npm.io/package/@404invalid-user/googlesheetsdb

## Dependencies (1)

- [googleapis](https://npm.io/package/googleapis.md) ^171.4.0

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 3.0.0 (latest) — 2026-05-31
- 1.3.0 — 2026-05-30
- 1.0.1 — 2022-10-28
- 1.2.9 — 2022-05-13
- 1.2.8 — 2022-05-13
- 1.0.0 — 2022-03-23

## README

# google sheetsdatabase
## get and add data to google sheets easily using objects 
 ![version](https://img.shields.io/badge/version-3.0.0-green) 
 googlesheetsdb is a package for the [googleapis](https://www.npmjs.com/package/googleapis) package that makes it more like the [mongoose](https://www.npmjs.com/package/mongoose) package when getting and adding data.

to be clear this should not be used as your main production database as you can only store 1000 or so documents

## setup
assuming you have already gone to https://docs.google.com/spreadsheets and made a sheet that looks some what like this ![sheets image](http://bisot.xyz/!invalid-user/qIndDtJSv.png)

first setup and login
```js
import SheetDB from '@404invalid-user/googlesheetsdb';

const sheetid = '1aFHYCF_2QyzSRQDyICWy--CWOXbbvDr7SwY4uJWcMoM' //this will be your sheet id you can find this in the url
const page = 'Sheet1' //the page in your sheet, you can find and edit these at the bottom of your sheets
const idname = 'id' //the name of your id cell (defaults to id)

//make a new instance and pass the details though
const sheet = new SheetDB(sheetid, page, idname);

//path to the json file you got from the google api console
//this takes an absolute path so we will use path to get it
const serviceAccountKeyPath = path.join(import.meta.dirname, '..', 'service-account-key.json');
//now you authenticate with google sheets
googleSheet.setup(serviceAccountKeyPath).catch(error => {
   console.log("something has gone wrong: " + error.stack || error)
});
```


## docs

### .findById(<id>) - get a row by the id cell name and returns an object
example assuming you have setup your sheet as sheet
```js
async function GetPerson() {
  const person = await sheet.findById('1');
  console.log("name: " + person.name);
  console.log("age: " + person.age);
}

GetPerson();
```

### ( await .findById(<id>)).save() - saves the changes you make to that object
example
```js
async function UpdateAge() {
  const person = await sheet.findById('1');
  console.log("name: " + person.name);
  console.log("age: " + person.age);
  //return is a string so number operations wont work
  person.age  = (parseInt(person.age)++).toString();
  person.save().catch(error => {
    console.log("error saving person likely no edit permission: " + error.stack || error);
  });
  //see your google sheet it should have updated unless your application doesn't have edit permission
}

UpdateAge();
```

### .getAll() - gets all columns and returns an array of objects
example
```js
async function GetPeople() {
  const people = await sheet.getAll();
  console.log("people: " + JSON.stringify(people));
  
  //get first person in array
  const person = people[0];
  console.log("name: " + person.name);
  console.log("age: " + person.age);
}

GetPeople();
```
### .create(<object>) - inserts new object to google sheets
example
```js
async function NewPerson() {
  const jon = {id: '4', name: 'jon', age: 23};
  sheet.create(jon).catch(error => {
    console.log("error creating person likely no edit permission: " + error.stack || error);
  });;
}

NewPerson();
```

## todo
- [x] find by id
- [x] .save()
- [x] .create()
- [ ] .find()
- [x] .findById()
- [x] .getAll()

## help and support
you can join my discord server [https://discord.gg/RYQbmj7](https://discord.gg/RYQbmj7) or [open an issue](https://github.com/404invalid-user/googlesheetsdb/issues)

---
_Source: https://npm.io/package/@404invalid-user/googlesheetsdb · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
