Skip to content

aes219/sheetflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



A lightweight package that allows you to use spreadsheet as a database very easily

Features

  • Easy-to-use methods
  • Write, read, update and delete data from spreadsheet
  • Search for specific queries in the sheet
  • Support for multiple sheets in one doc

Install

  • npm:
    npm i sheetflow
    
  • yarn:
    yarn add sheetflow
    

Basic Usage

Guide

Constructor Options

  • credentials

    The service account key file.

    • Create a project at https://console.cloud.google.com
    • Enable Sheets API. Go to APIs and services > Library, search and enable Google Sheets API
    • Create a service account. Go to Credentials > Create Credentials > Service Account
    • Select the newly created service account, go to Keys > Add new key > Create new key > Select JSON as type and save the JSON file at your project directory
  • sheet

    The base google sheet.

Methods

  • db.connect()

    Authorizes and connects to the Google Sheets API.
  • db.read()

    Read all the data from the current sheet - no parameters needed.
  • db.write([data])

    Write to the sheet, param data must be an array of strings.
  • db.update(data)

    Update a cell's value. The param data must be an object, sheetflow by default searches and updates the first entry that has the same value as the first prop of object data.
    const data = {
      id: "44",
      email: "cool@gmail.com"
    }
    db.update(data) // sets the email of entry by id "44" to cool@gmail.com
  • db.search(query)

    Search for a specific entry from the database, param query must be a string.
  • db.delete(rowIndex)

    Deletes the entry by the provided rowIndex.