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

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
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
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
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
 

Recently uploaded (20)

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
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
 
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
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
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
 

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 .