examples on this site. When I was developing parse.com api class for VBA , part of the motivation was that I would be able to share data across many platforms (IOS,Android,javScript etc) - including Google Apps Script. As you will know if you a regular visitor on this site, From VBA to Google Apps Script is a regular topic, and creating a GAS version of parse.com - nosql database for VBA was pretty straightforward. Since the implementation is very similar, I recommend you read up on parse.com - nosql database for VBA for concepts and getting started with Parse. Google Apps Script already has a noSQL database - scriptDB. I use it a lot, and have plenty of NOTE: You can now use Database abstraction with google apps script to access parse as a backend. If you want to use this library directly, for compatibility and performance reasons, and because of the changes in GAS Propertystores, I recommend you use the cParseCom implementation of getParsed, as per the example below, where you have set up a property that looks like this in your key store. {applicationID:"your Parse-applicationID", restAPIKey:"your Parse-REST-API-Key"} function tDurect(){ var userStore = PropertiesService.getUserProperties(); var parseCom = cParseCom.getParsed("gasParseData",JSON.parse(userStore.getProperty("parseKeys"))); } Here's a few primer slides to get startedAuthenticationNote - although the section below still works, it has been superseded by the cParseCom.getParsed() function, as mentioned at the beginning of this article. Just like in the VBA version, there is a one off authentication needed to register your credentials. Once done, you don't need to bother with them again as the API looks in your UserProperties for an encrypted version of them. For more on encryption used see this post.
The one off code you need looks like this.
function firstTimeParseCom () { // run this once for each user/scope combination parseCom.setRegistryPackage ( "parse","default",{restAPIKey: "your rest API key", applicationID:"your application id"}); } A note about UserProperties and libraries.In the VBA version, credentials are encrypted and stored in the Windows registry. In the GAS version, they are stored in your UserProperties. This means they are available to any script you are running, but not to libraries you are using. I'll provide the library keys for all this later, but in order to keep your credentials private, I recommend the following setup.
Something like this Example workbook scriptLet's say you want to be able to create a a couple of parse Tables (they are called classes) from a workbook. Your script would look this, and you would include a reference to you parseCom library to make it all happen.
function testPopulate() { populateFromName ("gasParseCustomers"); populateFromName ("gasParseData"); } function populateFromName (sheetName) { parseCom.populateFromSheetValues(SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName).getDataRange().getValues(), sheetName); } parseCom libraryThis would be a standalone script that would act as a gateway to the parse API, and also access your UserProperties for your parse credentials. The code in it doesn't need to be modified, just copied into a script that you own.
And here's the code to do it. You can take a copy of this script. There are also some examples there.
Adding a reference to cParseComBefore you can use your copy of parseCom, you'll need to reference the cParseCom library - here's the resource property MMaKU0wHrNShUwFypY3nM8iz3TLx7pV4j Authentication for the first time.As described earlier, set up your credentials in your User Properties by making a private script, adding a reference to your parseCom library, entering your parse credentials and running this function, function firstTimeParseCom () { // run this once for each user/scope combination parseCom.setRegistryPackage ( "parse","default",{restAPIKey: "your rest API key", applicationID:"your application id"}); } Now you are good to go. All scripts you write will reference your parseCom library. Here's some more detail and examples For help and more information join our forum,follow the blog or follow me on twitter .
|
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Parse.com >