DriverProperties

This is the the driver for DB.PROPERTIES described in Database abstraction with google apps script 

The library reference is MrpyO-B3fO-b1NG3LZ4UzaKi_d-phDA33
 

Reference

This driver uses one of objects returned by the Google Apps Script Properties service. It is only usable for small databases, since there is a limit on property size, but is has all the same features (query/update/sort/limit/get/remove/save) as the other drivers and caching and locking are implemented.

The siloId is the property key, and the object to pass is the property object to use. 

Here's how to get a handler.

  var propertiesHandler = new cDataHandler.DataHandler('avengers',cDataHandler.dhConstants.DB.PROPERTIES,undefined, 'myproperties',UserProperties);  
 

Example

This example gets some data from Driver Import.io, writes it as a database to both a drive JSON file and the user properties, and does a couple of queries on the result. 

function driveTest6() {


var importioHandler = new cDataHandler.DataHandler
('caff10dc-3bf8-402e-b1b8-c799a77c3e8c',cDataHandler.dhConstants.DB.IMPORTIO,
undefined,'myimportio',JSON.parse(UserProperties.getProperty("importioKeys")));
var importioData = importioHandler.query({searchterm: "avengers 2"},undefined,1);
if (importio.handleCode <0) throw (JSON.stringify(importioData));

// write to a property
var propertiesHandler = new cDataHandler.DataHandler('avengers',cDataHandler.dhConstants.DB.PROPERTIES,undefined, 'myproperties',UserProperties);
propertiesHandler.remove();
var result = propertiesHandler.save (importioData.data);
if (result.handleCode <0) throw (JSON.stringify(result));
Logger.log(propertiesHandler.query(undefined,{limit:2,sort:'skills'},1));


// write to a drive
var driveHandler = new cDataHandler.DataHandler('avengers.json',cDataHandler.dhConstants.DB.DRIVE,undefined,'/datahandler/driverdrive');
driveHandler.remove();
var result = driveHandler.save (importioData.data);
if (result.handleCode <0) throw (JSON.stringify(result));
Logger.log(driveHandler.query(undefined,{limit:2,sort:'skills'},1));



}

The code

For help and more information join our forum,follow the blog or follow me on twitter .



Comments