Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gsheet-to-db

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gsheet-to-db

Use Google Sheets as a database perform all CRUD opraction

  • 2.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

gsheet-to-db

npm

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
idNameStatusSalary
1WilsonFullTime$40,000
2saurabhFullTime$120,000
3herryFullTime$40,000
 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

{
    "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

  npm i gsheet-to-db

Import

const { Gsheet } =  require("gsheet-to-db")
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

spreadsheetIdyou 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

linkedin

Keywords

FAQs

Package last updated on 07 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc