Query parse.com from GAS

First up we'll query the colortable  created in Updating parse.com, using the parse REST API. We can't use the javaScript API in dome way from GAS, because it's not caja compliant - if it were, we might be able to approach it in the same way as in Updating parse.com.

Nevertheless it's pretty straightforward - here's the parse specific code. The colors can be selected by scheme, label, name, code and key parameters. 


parse.com specific code


It needs a few basic utility functions as used all over on this site from the mcpher shared library, and you would also need to create a function to get your own parse.com keys that would look something like this

function getKeys() {
  return {
    applicationId : "a..whatever..8",
    restKey : "u..whatever...T"} ;
}


It's worth a few words on the queryArray() function of the cParseCom object. In order to harmonize the number of fetches required to get a lot of data between parse and scriptdb (so they can be compared), I'm using this method to handle getting the data in batches, up to the limit specified. This also gets over any default limits by either approach. Here's the code - its simply returns an array of size (limit) or everything matching if limit is 0. It handles the batching up process in the same way as its equivalent in the scriptDB silo object.

The results

Here's a live query. You can get jSonp also by specifying a callback parameter. This will get the first two entries from the dulux color scheme, using parse.com as the provider

https://script.google.com/macros/s/AKfycbzSdgK85uGHdQ9m076QkPV0B9a2kkgh7JHDmV8kzRgtkriSIwTn/exec?limit=2&scheme=dulux&provider=parse

For more about parse.com, see Parse.com
For help and more information join our forumfollow the blogfollow me on twitter

You want to learn Google Apps Script?

Learning Apps Script, (and transitioning from VBA) are covered comprehensively in my my book, Going Gas - from VBA to Apps script, All formats are available from O'ReillyAmazon and all good bookshops. You can also read a preview on O'Reilly

If you prefer Video style learning I also have two courses available. also published by O'Reilly.
Google Apps Script for Developers and Google Apps Script for Beginners.



Comments