Skip to content

mattcoulter7/Google-Sheets-Database

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Google-Sheets-Database

This NPM Package allows you to use a Google Spreadsheet as a database within your Node Js project.

How to use

There are 2 setup parts in order to get this package working. The first part is setting up the API endpoint that calls routes to my script endpoint within a Google Script on your Google Drive. The second part is installing the NPM package and connecting to your the database via the deployment ID.

Part 1: Google

  1. Create a new google script file
    image

  2. Add the MCLib script as a library to your script 1wuipW_9oqNOq1l0bdbLiIrt5JnX8xzI_Bb7jA7rRzArfpfmys_7wNlgU
    image image image

  3. Add doPost method that redirects to the MCLib doPost method
    const doPost = (e) => MCLib.doPost(e)
    image

  4. Deploy your script as an Web app
    image image image

  5. Authorize access
    image image image image

  6. Copy the Deployment ID to your clipboard image

Part 2: Node

  1. Set up your Node Project with node init

  2. Load this library into your project
    const googlesheetdatabase = require("google-sheet-database")

  3. Create a schema for a new table
    SampleSchema = new googlesheetdatabase.schema( ["id", "column1", "column2", "column3"] )

  4. Create a model for the schema
    SampleModel = new googlesheetdatabase.model("SampleModel", SampleSchema)

  5. Connect to the database
    googlesheetdatabase.connection.connect({ databaseName: YOUR_DATABASE_NAME, apiKey: YOUR_DEPLOYMENT_ID })

Performing CRUD Operations

WIthin this file you will see examples of all the different CRUD operations that can be performed. Below lists them for reference.

  • Inserting a single record (CREATE)
  • Update a single record (UPDATE)
  • Select a single record (READ)
  • Deleting a single record (DELETE)
  • Inserting Multiple Records (CREATE)
  • Update multiple records (UPDATE)
  • Select (READ)
  • Select with where condition (READ)
    image

Viewing the spreadsheet

image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published