-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspreadsheet.js
36 lines (25 loc) · 939 Bytes
/
spreadsheet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const { GoogleSpreadsheet} = require('google-spreadsheet');
const credenciales = require('./keys/credenciales.json');
let googleId = "1BAxDSHZq34ETyfKQC1Bdo4QDrabJjX1buoWnYs89q1o";
async function accederGooogleSheet(){
const documento = new GoogleSpreadsheet(googleId);
await documento.useServiceAccountAuth(credenciales);
await documento.loadInfo();
const sheet = documento.sheetsByIndex[1];
//console.log(sheet);
const registros = await sheet.getRows();
// console.log(registros);
return registros;
}
//accederGooogleSheet()
async function guardarVideo(pObjeto){
const documento = new GoogleSpreadsheet(googleId);
await documento.useServiceAccountAuth(credenciales);
await documento.loadInfo();
const sheet= documento.sheetsById[0];
await sheet.addRow(pObjeto);
}
module.exports = {
accederGooogleSheet : accederGooogleSheet,
guardarVideo : guardarVideo,
}