DataHandler supports a host of backends. One of the problems with all the drivers being in that handler library is that when you create an app with say, a backend of sheets, its going to ask for authorization to access a whole bunch of other services - for example, Fusion tables and so on - which can be confusing for the user. This library provides an alternative approach - where the driver library is passed to the abstraction handler. This way, authorization is only sought for the specific driver(s) being used.The
To use this method, you'll need the cDbAbstraction library (MHfCjPQlweartW45xYs6hFai_d-phDA33) along with the library reference of the driver(s) you want to use.
Remember that you do not need the DataHandler library with this method. Instead, you use its underlying cDbAbstraction library, plus only the specific driver libraries of your choice.
Getting a handler is very straightforward.
Thereafter, the parameters are similar to those in DataHandler.
Here's an example of getting a sheet handler, where I've included a reference to DriverSheet and DriverDbAbstraction in my script.
Note that the property names are all lower case - this is to align with the parameters in the DataHandler REST API
By default caching is applied to all backends. If you are using a shared library, then the default cache is specific to the user of the library (the key is also encrypted). To change that behavior you can do any of these.
The example below restricts the cache scope to a specific user, using the cache belonging to the calling script (not the library).
This example could be used for public data where you want to leverage caching amongst all library users
This example could be used for community data where you want to leverage caching amongst a group of users who all know a hard to guess key - this is called a cache community key. Although we are using a public cache, the encrypted keys will be salted and only findable by handlers with the same community cache key
Query results are cached against a hashed/encrypted version of the query. Being able to know if a cache entry is fresh is achieved as follows, and is completely automatic
The DataHandler class actually uses the DbAbstraction class. The only convenience it offers is that it already knows about all the supported libraries - the down side being that the calling program needs to authorize access to potentially unneeded libraries. The recommended approach is to use DbAbstraction.
Here' s how the data handler passes through its parameters to get a handle. Note that only a subset of the DbAbstraction options are supported by the DataHandler.
See Database abstraction with google apps script for more on this.
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Database abstraction and Google Apps Script >