# gsheet-to-db

> Use Google Sheets as a database perform all CRUD opraction

Latest version **2.1.6** (published 2024-01-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install gsheet-to-db
pnpm add gsheet-to-db
yarn add gsheet-to-db
bun add gsheet-to-db
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.6 |
| Published | 2024-01-07 |
| First published | 2022-10-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | saurabh singh |
| Maintainers | saurabhgkp |
| Keywords | google, sheets, spreadsheet to DB, database |

## Links

- npm: https://www.npmjs.com/package/gsheet-to-db
- Repository: https://github.com/saurabhgkp/gsheet-to-db
- Homepage: https://github.com/saurabhgkp/gsheet-to-db#readme
- Issues: https://github.com/saurabhgkp/gsheet-to-db/issues
- npm.io page: https://npm.io/package/gsheet-to-db

## Dependencies (1)

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

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 2.1.6 (latest) — 2024-01-07
- 2.1.5 — 2024-01-07
- 2.1.4 — 2023-12-20
- 2.1.3 — 2023-12-20
- 2.0.3 — 2023-12-20
- 2.0.2 — 2023-12-20
- 2.0.1 — 2023-12-19
- 2.0.0 — 2023-12-19
- 1.0.5 — 2022-10-07

## README

# gsheet-to-db
[![npm](https://img.shields.io/npm/dt/gsheet-to-db)](https://www.npmjs.com/package/gsheet-to-db)
 ## Example for gsheet-to-db GitHub repo link
 https://github.com/saurabhgkp/gsheet-to-db-example

  ####  Easy to use and implement
SheetDB will turn your sheets into a  **JSON API**, easy to integrate with other tools and all programming languages.
## operations
####  You can read and edit your spreadsheet with GET, POST, PUT and DELETE requests with just a few lines of code.

## FAQ

#### In Google Sheets you have to set data in header vale by manually first Field must be an 'id' and remaining is upto you

| id            | Name    | Status   | Salary   |
| ------------- | ------- | -------- | -------- |
| 1             | Wilson  | FullTime | $40,000  |
| 2             | saurabh | FullTime | $120,000 |
| 3             | herry   | FullTime | $40,000  |

```bash
 id |	 Name |    Status |	Salary
this field Are Add by manually field
may Different (As you Want 'id' is First Field !importent)

```

#### passing data in body is like

```bash

{
    "B":"herry",
    "C":"FullTime",
    "D":"$40,000"
}


```

always use capital letters ===>
Don't A, This is use for 'id' use B C D to the Z for passing data
## prerequisite

Activate Google Sheets API. Go to the Google console developer and enable Google Sheets API.
https://console.cloud.google.com/apis/dashboard And get JSON key.
DO NOT commit the JSON key! Add the file to .gitignore now and import it into
the code! Or use environment variables.

## Installation

Install my-project with npm

```bash
  npm i gsheet-to-db

```

Import

```bash
const { Gsheet } =  require("gsheet-to-db")
```


```bash
const  gdata  =  new  Gsheet("./keyFile.json", "spreadsheetId", "sheetName")

 let  data1  =  await  gdata.findAll()
 let  data2  =  await  gdata.findById(id)
 let  data3  =  await  gdata.create(data)
 let  data4  =  await  gdata.deleteById(id)
 let  data5  =  await  gdata.updateById(id, data)
```
##  Code  Explanation
`"./keyFile.json"` 
 this keysFile you can get it from Google console developer
 
`spreadsheetId`you can get from spreadsheet URL for example 
`https://docs.google.com/spreadsheets/d/`1JmpRfmEfSdVAxAu2SRvzsnswI1-ln-3F_1xtlg`/edit?pli=1#gid=0`
here after /d/ and before /edit is your
 spreadsheetId ="1JmpRfmEfSdVAxAu2SRvzsnswI1-ln-3F_1xtlg"
 
 `sheet name` can be found at the bottom of spreadsheets by default is something like "sheet1"
 
` let  data3  =  await  gdata.create(data)`
here data must be started from "B" not  "A". "A" is reserved for "id" 
for example
```
{
    "B":"herry",
    "C":"FullTime",
    "D":"$40,000"
    ...
}
```
for any help, you can DM me on LinkedIn
## 🔗 Links

[![linkedin](https://img.shields.io/badge/linkedin-0A66C2?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/saurabh-singh-841590192)

---
_Source: https://npm.io/package/gsheet-to-db · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
