SlideShare a Scribd company logo
1 of 15
Parse.com – with
GAS
HOW TO USE A CLOUD BASED NOSQL DATABASE WITH
GOOGLE APPS SCRIPT

EXCEL LIBERATION
What is parse.com?
A noSQL database
SDK for multiple platforms, including IOS and Android
Cloud based script execution
Built in analytics and dashboards
Role based security
Free for most of us

Easy to use and to get started with
Best for smaller datasets
Read more at parse.com
Why use parse.com with GAS?
Google Apps Script already has its own noSQL database – scriptDB – fine for staying inside GAS
Using Parse allows GAS to easily share data with other platforms and across workbooks
Is easier to get started with than many other noSQL databases
There is a restAPI that’s pretty easy to implement a GAS wrapper class for
There’s already a Parse VBA API – this one is virtually the same. You can write code in one and
copy to the other with only minor language syntax changes.
You can use oAuth2 if you want, but this also adds parse.com authentication

Parse.com is more table like in structure. ScriptDB is more free form. Both approaches have
advantages
Because we can
Authentication using GAS API
Once only per user

Encrypt parse.com
restAPI and
application ID Keys

Store in User
Properties

If you want you
can add oAuth2 to
further control
access

Subsequent accesses from any Google Apps Script

Get from User
Properties

Decrypt restAPI
and application
ID keys

Avoids the
problem of
needing keys in
every Script

Access
Parse.com
Code for Authentication
First time to register and encrypt credentials for this user

A Parse Class is
like a Table

function firstTimeParseCom () {
// run this once for each user/scope combination
parseCom.setRegistryPackage ( "parse","default",{restAPIKey: "your rest API key",
applicationID:"your application id"});
}
Thereafter from any script executed as this user
var parseCom = getParsed("VBAParseCustomers");
Code for a Query

Queries are by
example. Default
is to get all objects
in the class

function testparsequery () {
// get a number of items that match a query by example
var w = getParsed("VBAParseData").getObjectsByQuery( {customerid:1},{order:'-value'});
//test if it worked, and do something with the results
if (w.isOk() ){
Logger.log( "all is ok"+ JSON.stringify(w.jObject()));
}
else {
throw( "failed to do query:" + w.browser().url() + ":" + w.browser().status() + ":" + w.browser().text());
}
}

All methods are
chainable
JSON.stringify(getParsed("VBAParseData").getObjectsByQuery( {customerid:1},{order:'-value'}).jObject());

Or as a one liner
Get by objectID
Each parse object
function testGetItemByUniqueId () {
(like a row) gets
// get a handle for this class
assigned a unique
var parseCom = getParsed("VBAParseCustomers");
// use a valid unique ID to get the data
ID
if (parseCom.getObjectById("VbzHLEte62").isOk()) {
Logger.log (JSON.stringify(parseCom.jObject()));
}
else {
throw ("failed to get object:" + parseCom.browser().url() + ":" + parseCom.browser().status() + ":"
+ parseCom.browser().text());
}
}
All methods are
Or as a one liner

chainable

JSON.stringify(getParsed("VBAParseCustomers").getObjectById(("VbzHLEte62").jObject());
JSON.stringifiable object is returned
from every operation
{
"address":"584-5478 Et Road",
"city":"Hastings",
"company":"Eu Accumsan Sed Inc.",
"coordinates":"38.2264, 75.04849",
"country":"Comoros",
"customerid":100,
"email":"tincidunt.nibh@Curabitur.net",
"name":"Contreras",
"region":"NI",
"zip":"12396",
"createdAt":"2013-11-26T14:36:40.517Z",
"updatedAt":"2013-11-26T14:36:40.517Z",
"objectId":"SmnyjZKs9m"
}

Results are in the
.jObect property
of cParseCom
Deleting objects
getParsed(‘a parse class’).batch().deleteObjects()

Or just some
getParsed(‘aclass’).batch().deleteObjects( {customerID:1});

.deleteObjects will
delete all objects
(rows) that match
its query.

Delete operations
can be ‘batched’
Creating objects
getParsed(“aclass”).batch().createObject(job)

Delete first, if you don’t want a new object to be created
getParsed(“aclass”). getObjectsByQuery(job).batch().delete().createObject(job)

.createObjects will
create a new class
if it doesn’t exist

Create operations
can be ‘batched’
Updating objects
function testparseUpdate () {
// get some items by query and change the scheme name to something else
var w = getParsed("VBAParseData").batch(true).updateObjects({customerid:39},
{customerid:1}).batch(false);
if (w.isOk() ){
Logger.log( "all is ok"+ JSON.stringify(w.jObject()));
}
else {
throw( "failed to do query:" + w.browser().url() + ":" + w.browser().status() + ":" +
w.browser().text());
}
}
Or as a one liner

.createObjects will
create a new class
if it doesn’t exist

Update operations
can be ‘batched’

JSON.stringify(getParsed("VBAParseData").batch(true).updateObjects({customerid:39},
{customerid:1}).batch(false).jObject());
Counting objects in a class
Logger.log (getParsed("VBAParseCustomers").count({country:"Libya"}));

Or total in class
Logger.log (getParsed("VBAParseData").count());

.count() will return
the total number
of records in the
class or that match
a query if one is
given
Copying a sheet to a parse class
// copy two sheets to parse.com
function testPopulate() {
populateFromName ("gasParseCustomers");
populateFromName ("gasParseData");
}

Code for populateFromName
function populateFromName (sheetName) {
parseCom.populateFromSheetValues(SpreadsheetApp.getActiveSpreadsheet()
.getSheetByName(sheetName).getDataRange().getValues(), sheetName);
}

Call shared scripts
from a workbook
with the data
Typical setup
Reference your
parseCom library in
each of your scripts
Your scripts

Your
spreadsheets

UserProperties
Your encrypted
parse.com
credentials are
stored here

Create your own
parseCom library –
shared in between
your scripts

Copy parseCom
library code from
here

cParseCom library – shared
by everyone, owned by Excel
Liberation

Reference this project key in
your parseCom library

MMaKU0wHrNShUwFy
pY3nM8iz3TLx7pV4j
Getting started
Register with parse.com, create an application and get an applicationID and a restAPI key
Set up your parseCom script with this code
Add a reference to cParseCom at MMaKU0wHrNShUwFypY3nM8iz3TLx7pV4j

Create a first time script, add a reference to your parseCom library and run this
function firstTimeParseCom () {
// run this once for each user/scope combination
parseCom.setRegistryPackage ( "parse","default",{restAPIKey: "your rest API key",
applicationID:"your application id"});
}

Run some of the examples in parseCom

Create some scripts that reference your parseCom library
Get some testData (there’s some here), reference your parseCom, and load some data from Worksheets
Read about how all this works and learn how to do more complex operations at Excel Liberation
For help and more information visit me on GooglePlus, join our forum, follow the blog or follow me on twitter .

More Related Content

More from Bruce McPherson

Do something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databasesDo something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databasesBruce McPherson
 
Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2Bruce McPherson
 
Do something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilterDo something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilterBruce McPherson
 
Do something in 5 with gas 7-email log
Do something in 5 with gas 7-email logDo something in 5 with gas 7-email log
Do something in 5 with gas 7-email logBruce McPherson
 
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...Bruce McPherson
 
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetDo something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetBruce McPherson
 
Do something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing appDo something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing appBruce McPherson
 
Do something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a databaseDo something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a databaseBruce McPherson
 
Do something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as databaseDo something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as databaseBruce McPherson
 
Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed versionBruce McPherson
 
Using script db as a deaddrop to pass data between GAS, JS and Excel
Using script db as a deaddrop to pass data between GAS, JS and ExcelUsing script db as a deaddrop to pass data between GAS, JS and Excel
Using script db as a deaddrop to pass data between GAS, JS and ExcelBruce McPherson
 
JavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primerJavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primerBruce McPherson
 
VBA API for scriptDB primer
VBA API for scriptDB primerVBA API for scriptDB primer
VBA API for scriptDB primerBruce McPherson
 
Javascript like objects and JSON processing in VBA
Javascript like objects and JSON processing in VBAJavascript like objects and JSON processing in VBA
Javascript like objects and JSON processing in VBABruce McPherson
 

More from Bruce McPherson (16)

Do something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databasesDo something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databases
 
Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2
 
Goa tutorial
Goa tutorialGoa tutorial
Goa tutorial
 
Do something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilterDo something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilter
 
Do something in 5 with gas 7-email log
Do something in 5 with gas 7-email logDo something in 5 with gas 7-email log
Do something in 5 with gas 7-email log
 
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
 
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetDo something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
 
Do something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing appDo something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing app
 
Do something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a databaseDo something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a database
 
Do something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as databaseDo something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as database
 
Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed version
 
Dbabstraction
DbabstractionDbabstraction
Dbabstraction
 
Using script db as a deaddrop to pass data between GAS, JS and Excel
Using script db as a deaddrop to pass data between GAS, JS and ExcelUsing script db as a deaddrop to pass data between GAS, JS and Excel
Using script db as a deaddrop to pass data between GAS, JS and Excel
 
JavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primerJavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primer
 
VBA API for scriptDB primer
VBA API for scriptDB primerVBA API for scriptDB primer
VBA API for scriptDB primer
 
Javascript like objects and JSON processing in VBA
Javascript like objects and JSON processing in VBAJavascript like objects and JSON processing in VBA
Javascript like objects and JSON processing in VBA
 

Recently uploaded

Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Recently uploaded (20)

Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

parse.com - how to use a noSQL data base for Google Apps Script

  • 1. Parse.com – with GAS HOW TO USE A CLOUD BASED NOSQL DATABASE WITH GOOGLE APPS SCRIPT EXCEL LIBERATION
  • 2. What is parse.com? A noSQL database SDK for multiple platforms, including IOS and Android Cloud based script execution Built in analytics and dashboards Role based security Free for most of us Easy to use and to get started with Best for smaller datasets Read more at parse.com
  • 3. Why use parse.com with GAS? Google Apps Script already has its own noSQL database – scriptDB – fine for staying inside GAS Using Parse allows GAS to easily share data with other platforms and across workbooks Is easier to get started with than many other noSQL databases There is a restAPI that’s pretty easy to implement a GAS wrapper class for There’s already a Parse VBA API – this one is virtually the same. You can write code in one and copy to the other with only minor language syntax changes. You can use oAuth2 if you want, but this also adds parse.com authentication Parse.com is more table like in structure. ScriptDB is more free form. Both approaches have advantages Because we can
  • 4. Authentication using GAS API Once only per user Encrypt parse.com restAPI and application ID Keys Store in User Properties If you want you can add oAuth2 to further control access Subsequent accesses from any Google Apps Script Get from User Properties Decrypt restAPI and application ID keys Avoids the problem of needing keys in every Script Access Parse.com
  • 5. Code for Authentication First time to register and encrypt credentials for this user A Parse Class is like a Table function firstTimeParseCom () { // run this once for each user/scope combination parseCom.setRegistryPackage ( "parse","default",{restAPIKey: "your rest API key", applicationID:"your application id"}); } Thereafter from any script executed as this user var parseCom = getParsed("VBAParseCustomers");
  • 6. Code for a Query Queries are by example. Default is to get all objects in the class function testparsequery () { // get a number of items that match a query by example var w = getParsed("VBAParseData").getObjectsByQuery( {customerid:1},{order:'-value'}); //test if it worked, and do something with the results if (w.isOk() ){ Logger.log( "all is ok"+ JSON.stringify(w.jObject())); } else { throw( "failed to do query:" + w.browser().url() + ":" + w.browser().status() + ":" + w.browser().text()); } } All methods are chainable JSON.stringify(getParsed("VBAParseData").getObjectsByQuery( {customerid:1},{order:'-value'}).jObject()); Or as a one liner
  • 7. Get by objectID Each parse object function testGetItemByUniqueId () { (like a row) gets // get a handle for this class assigned a unique var parseCom = getParsed("VBAParseCustomers"); // use a valid unique ID to get the data ID if (parseCom.getObjectById("VbzHLEte62").isOk()) { Logger.log (JSON.stringify(parseCom.jObject())); } else { throw ("failed to get object:" + parseCom.browser().url() + ":" + parseCom.browser().status() + ":" + parseCom.browser().text()); } } All methods are Or as a one liner chainable JSON.stringify(getParsed("VBAParseCustomers").getObjectById(("VbzHLEte62").jObject());
  • 8. JSON.stringifiable object is returned from every operation { "address":"584-5478 Et Road", "city":"Hastings", "company":"Eu Accumsan Sed Inc.", "coordinates":"38.2264, 75.04849", "country":"Comoros", "customerid":100, "email":"tincidunt.nibh@Curabitur.net", "name":"Contreras", "region":"NI", "zip":"12396", "createdAt":"2013-11-26T14:36:40.517Z", "updatedAt":"2013-11-26T14:36:40.517Z", "objectId":"SmnyjZKs9m" } Results are in the .jObect property of cParseCom
  • 9. Deleting objects getParsed(‘a parse class’).batch().deleteObjects() Or just some getParsed(‘aclass’).batch().deleteObjects( {customerID:1}); .deleteObjects will delete all objects (rows) that match its query. Delete operations can be ‘batched’
  • 10. Creating objects getParsed(“aclass”).batch().createObject(job) Delete first, if you don’t want a new object to be created getParsed(“aclass”). getObjectsByQuery(job).batch().delete().createObject(job) .createObjects will create a new class if it doesn’t exist Create operations can be ‘batched’
  • 11. Updating objects function testparseUpdate () { // get some items by query and change the scheme name to something else var w = getParsed("VBAParseData").batch(true).updateObjects({customerid:39}, {customerid:1}).batch(false); if (w.isOk() ){ Logger.log( "all is ok"+ JSON.stringify(w.jObject())); } else { throw( "failed to do query:" + w.browser().url() + ":" + w.browser().status() + ":" + w.browser().text()); } } Or as a one liner .createObjects will create a new class if it doesn’t exist Update operations can be ‘batched’ JSON.stringify(getParsed("VBAParseData").batch(true).updateObjects({customerid:39}, {customerid:1}).batch(false).jObject());
  • 12. Counting objects in a class Logger.log (getParsed("VBAParseCustomers").count({country:"Libya"})); Or total in class Logger.log (getParsed("VBAParseData").count()); .count() will return the total number of records in the class or that match a query if one is given
  • 13. Copying a sheet to a parse class // copy two sheets to parse.com function testPopulate() { populateFromName ("gasParseCustomers"); populateFromName ("gasParseData"); } Code for populateFromName function populateFromName (sheetName) { parseCom.populateFromSheetValues(SpreadsheetApp.getActiveSpreadsheet() .getSheetByName(sheetName).getDataRange().getValues(), sheetName); } Call shared scripts from a workbook with the data
  • 14. Typical setup Reference your parseCom library in each of your scripts Your scripts Your spreadsheets UserProperties Your encrypted parse.com credentials are stored here Create your own parseCom library – shared in between your scripts Copy parseCom library code from here cParseCom library – shared by everyone, owned by Excel Liberation Reference this project key in your parseCom library MMaKU0wHrNShUwFy pY3nM8iz3TLx7pV4j
  • 15. Getting started Register with parse.com, create an application and get an applicationID and a restAPI key Set up your parseCom script with this code Add a reference to cParseCom at MMaKU0wHrNShUwFypY3nM8iz3TLx7pV4j Create a first time script, add a reference to your parseCom library and run this function firstTimeParseCom () { // run this once for each user/scope combination parseCom.setRegistryPackage ( "parse","default",{restAPIKey: "your rest API key", applicationID:"your application id"}); } Run some of the examples in parseCom Create some scripts that reference your parseCom library Get some testData (there’s some here), reference your parseCom, and load some data from Worksheets Read about how all this works and learn how to do more complex operations at Excel Liberation For help and more information visit me on GooglePlus, join our forum, follow the blog or follow me on twitter .