This is the the driver for DB.DATASTORE described in Database abstraction with google apps script
The library reference is MPZF_EC6nOZFAjMRqCxEaUyz3TLx7pV4j
This tutorial references the the cDataHandler and cEzyOauth2, both of which have been superseded by cDbAbstraction and cGoa which are easier to implement. If you'd rather work with those, the slides below show an example.
There is a JSON API, and along with the new concepts of entities , paths, ancestors and tricky indexing it's quite difficult to get started with. It does have a GQL query language which is SQL-ish, but you can only use it for querying (not updating). It is also only really able to handle objects that are flat, and complicated queries need to have indexes pre-setup - in other words you need to know what you'l ask before you ask.
Since this is a database abstraction driver, I don't need the full capabilities of DataStore since I only need those that are present in other databases in the sub-universe. I also need to use Flattening an object with dot syntax to allow for multi level object storage and querying, and because of the limitation around pre-indexing, I need to do hybrid querying with some of it happening in datastore, and more complex constraints happening in the DataHandler.
Here's a quick primer.
Before you choose to use DataStore, you'll need to think about quotas. It's very easy to blow the free daily allowance - for any meaningful application you'll probably end up paying something. There is a quota dashboard on the Google Developers Cloud console.
The data abstraction library has caching enabled from the start, so any data taken from cache doesn't eat into your quota.
If you've been avoiding oAuth2, you can't. DataStore demands authentication. The DataHandler can accept and access token, and you can easily use EzyOauth2 - taking some pain out of Apps Script API authentication to get one for both web app and regular applications. More about that later.
Although Datastore has the concept of 'Transactions', you can't protect sections of code like you can when you use it with App Engine. I'm Using named locks with Google Apps Scripts to protect sensitive transactions.
There's a little bit of setting up to do
Here's some libraries you'll need or are used internally
As described in EzyOauth2 patterns, apps that require oAuth2 can be complicated. However, once you've copied the template, the pattern is simple and repeatable. Here are the steps
If this is not a webapp, then you need something that looks like this too, where dataStoreTest is your application that is going to d the work.
If you are interested in the implementation, you'll find the code here
If you've already used Database abstraction with google apps script then this will be familiar. The database access is the same for datastore as it is for any other backend. The only specific coding is setting up the handler. Here are 3 different setups for 3 different backends - datastore, parse.com and Drive. You'll notice they are very similar. In this i've opted out of analytics tracking, and turned off caching- since I'm going to run the same tests on each platform to make sure I get the same result. You'll find these tests in the Patterns template and you may find them useful to check out your set up.
Here's a set of tests - it doesn't matter which back end you are using. The code is the same.
See more like this in Database abstraction with google apps script
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Database abstraction and Google Apps Script >