Using ScriptDB as a noSQL database for non-Google Apps Script clients

A long time back now, I showed how to publish and prettify source code and scriptdb contents using Google Apps Script. This allows you to embed code or data samples in blog posts and so on.

For example, below is the Google Apps Script code to do it, being shown live from the GAS IDE, using this link

ScriptDB as a non-Google Apps Script noSQL database

It can take a number of sources aside from Google Apps Script (such as gist, any url) and can return various formats, and select specific functions. One of the things it can do is to publish data inside a scriptDB. It occurred to me that with a minor tweak I could use it to query scriptDB (using the regular scriptDB query by example) and return JSON selected data  to Excel, or any app that would know what to do with JSON – meaning that we’d have a ready made noSQL database.

Test database

For testing I’ll use the scriptDB in this example showing how to use multiple databases. I’ve created a merged database and embedded it using the link below

Query by example

It would be useful if we could selectively take results from that scriptDB. That would give us a noSQL database to be used as reference outside of Google Apps Script. Well – all I have to do is pass the JSON that describes the query I want to make, In this case I want all records for customer named john, so I can use scriptDB query by example language and pass it as a parameter{“data”:{“customer”:{“name”:”john”}}}

and here’s the result…

Prettification is just a prettification wrapper for the Google Apps Script webapp that actually does the work. Below is that wrapper code (it’s being used to display itself)

Altogether now

So if you want to get this data, unadorned, into a web app you can simply call the underlying Google Apps Script directly giving it a type of ‘jsonp’ – adding a callback if you need one.{“data”:{“customer”:{“name”:”john”}}}

Here’s a live query below from a simple web app

and here’s the source code

For more stuff like this see Excel Liberation

(function() { var po = document.createElement(‘script’); po.type = ‘text/javascript’; po.async = true; po.src = ‘’; var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(po, s); })();

Author: bm082975

Leave a Reply

Your email address will not be published. Required fields are marked *