Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Read and update data to a Drive spreadsheet

License

Notifications You must be signed in to change notification settings

trusk-official/drive-spreadsheet-sync

Repository files navigation

Drive Spreadsheet Sync

Read and save data to a Drive spreadsheet

Install

npm install

Example

const DriveSync = require('./index');
let testSpreadSheet;
try {
  testSpreadSheet = new DriveSync({
    service_account_credentials: {
      // A Google service account object
    },
    spreadsheet: 'SPREADSHEET_ID', // The big id in your spreadsheet url
    id_column: 'rid', // default rid, tests whether the data is new or must be updated
    sheet: 'My First Sheet', // default 0,
  });
} catch (e) {
  return e;
}

// save
testSpreadSheet.save([
  { rid: '1', firstname: 'John', lastname: 'Doe', phone: '555-555-555' },
  { rid: '2', firstname: 'Marty', lastname: 'McFly', phone: '555-555-555' },
  { rid: '3', firstname: 'I\'m', lastname: 'Batman', phone: '555-555-555' },
], (error) => { // or promise
  // Done
});

// read
testSpreadSheet.read((error, data) => { // or promise
  /*
  [{ rid: '1', firstname: 'John', lastname: 'Doe', phone: '555-555-555' },
  { rid: '2', firstname: 'Marty', lastname: 'McFly', phone: '555-555-555' },
  { rid: '3', firstname: 'I\'m', lastname: 'Batman', phone: '555-555-555' },]
  */
});

Result

About

Read and update data to a Drive spreadsheet

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •