O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Do something in 5 with gas 2-graduate to a database

3.293 visualizações

Publicada em

Here's how to migrate your backend Google Apps Script spreadsheet to a parse.com database in a few minutes.

Publicada em: Tecnologia
  • Follow the link, new dating source: ❶❶❶ http://bit.ly/39sFWPG ❶❶❶
       Responder 
    Tem certeza que deseja  Sim  Não
    Insira sua mensagem aqui
  • Dating for everyone is here: ❤❤❤ http://bit.ly/39sFWPG ❤❤❤
       Responder 
    Tem certeza que deseja  Sim  Não
    Insira sua mensagem aqui
  • Seja a primeira pessoa a gostar disto

Do something in 5 with gas 2-graduate to a database

  1. 1. do something useful with Apps Script in 5 minutes 2.Graduate to a database Bruce McPherson www.mcpher.com
  2. 2. Snippet objectives ● Use the lessons learned in ‘using a spreadsheet as a database’ ● Migrate data to a database - This example uses Parse.com Libraries used ● database abstraction ● driver sheet ● driver parse
  3. 3. Add libraries to script create a script Open resources Add references to libraries Mrckbr9_w7PCphJtOzhzA_Cz3TLx7pV4j MHfCjPQlweartW45xYs6hFai_d-phDA33 Mhr42c9etIE-fQb2D9pwW0ai_d-phDA33
  4. 4. Sign up to Parse.com ● Sign up to parse.com ● Create an application ● Get api keys We’re going to need the ● Application ID ● REST API Key
  5. 5. Store keys in properties We’ll use the script properties Just need to run this once function storeMyKeys () { PropertiesService.getScriptProperties().setProperty( "parseKeys", JSON.stringify ({ restAPIKey:'9oQAS9MO2fccccccccccccccccn4vp8', applicationID:'kaIR5Tak4Ycccccccccczl1TgyO2' })); }
  6. 6. layout what you are going to do function myFunction() { // open spreadsheet as database // get all the data // open parse.com database // delete any data already there // write the data // check count against original }
  7. 7. Get a handler for the sheet https://docs.google.com/spreadsheets/d/14xvwnQwhvw4jSGRBo7ZbJvNaNu438-5mMl2u_TJswlw/edit?usp=sharing // open spreadsheet as database var handler = new cDbAbstraction.DbAbstraction (cDriverSheet, { siloid:'carrierCodes', dbid:'14xvwnQwhvw4jSGRBo7ZbJvNaNu438-5mMl2u_TJswlw', }); if (!handler.isHappy()) throw 'unable to open sheet';
  8. 8. Get all the data // get all the data var result = handler.query(); if (result.handleCode < 0) throw result.handleError;
  9. 9. Get a handler for parse.com // open parse.com database var parseHandler = new cDbAbstraction.DbAbstraction (cDriverParse, { siloid:'carrierCodes', driverob:JSON.parse( PropertiesService.getScriptProperties().getProperty("parseKeys")) }); if (!parseHandler.isHappy()) throw 'unable to open parse.com';
  10. 10. Delete any parse.com data // delete any data already there var parseResult = parseHandler.remove(); if (parseResult.handleCode < 0) throw parseResult.handleError;
  11. 11. Migrate the data over from Sheet // write the data var parseResult = parseHandler.save(result.data); if (parseResult.handleCode < 0) throw parseResult.handleError; check it - using the parse.com dashboard
  12. 12. Check the counts match // check count against original if (parseHandler.count().data[0].count !== handler.count().data[0].count) throw 'oops'
  13. 13. Go and play on parse.com Repeat the examples in ‘using a spreadsheet as a database’ The only difference is how you get a handler. // open spreadsheet as database var handler = new cDbAbstraction.DbAbstraction (cDriverSheet, { siloid:'carrierCodes', dbid:'14xvwnQwhvw4jSGRBo7ZbJvNaNu438-5mMl2u_TJswlw', }); // open parse.com database var parseHandler = new cDbAbstraction.DbAbstraction (cDriverParse, { siloid:'carrierCodes', driverob:JSON.parse( PropertiesService.getScriptProperties().getProperty("parseKeys")) });
  14. 14. Follow up materials Take a copy of this script Take a copy of the sheet Take a copy of these slides Join me on G+, or the G+ community More on desktop liberation More on database abstraction

×