@methodus/google-spreadsheet
v2.0.0
Published
Google Spreadsheets V4 Data API -- simple interface to read/write rows/cells, manage sheets
Downloads
11
Readme
V4 Google Spreadsheet Access (node.js)
This is a CRUD based operations package for Google sheets.
API
import { Sheet, getSheet, SheetDataResult } from '@methodus/google-spreadsheet';
const sheet:Sheet = getSheet(sheetId, {client_email: '[email protected]', private_key: 'XXXXXXXXXXXX'});
Get filtered rows
function filter(row: SpreadsheetRow<Model>){
return row.data.email === email
}
const result = sheet.query<Model>('Sheet1', filter, start, end, sorts);
Insert
const data = new Model();
const result = sheet.insert<Model>('Sheet1',data);
const result = sheet.insertMany<Model>('Sheet1',[data]);
Update
const data = new Model();
data.keyid = keyvalue;
const result = sheet.update<Model>('Sheet1',data);
function filter(row: SpreadsheetRow<Model>){
return row.data.email === email
}
const result = sheet.updateBy<Model>('Sheet1',filter, data);
Delete
const data = new Model();
data.keyid = keyvalue;
const result = sheet.delete<Model>('Sheet1',data);
const result = sheet.deleteMany<Model>('Sheet1',[keyvalue,keyvalue,keyvalue]);