2.0.1 • Published 7 months ago
sheetflow v2.0.1
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 enableGoogle 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.
id
The Google doc ID, obtain it from the url :- https://docs.google.com/spreadsheets/d/1SmVEJqgPVDu6_0TyusWpAX7xWV7c6GGrTyv72aY38ac/edit?usp=sharing id for the above sheet:1SmVEJqgPVDu6_0TyusWpAX7xWV7c6GGrTyv72aY38ac
name
The sheet name from the google doc, you can have multiple class instances for each sheet.range
The range of the stored data, if you don't know what this is just putA:Z
Methods
Authorizes and connects to the Google Sheets API.db.connect()
Read all the data from the current sheet - no parameters needed.db.read()
Write to the sheet, param data must be an array of strings.db.write([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.db.update(data)
const data = { id: "44", email: "cool@gmail.com" } db.update(data) // sets the email of entry by id "44" to cool@gmail.com
Search for a specific entry from the database, param query must be a string.db.search(query)
Deletes the entry by the provided rowIndex.db.delete(rowIndex)