SlideShare a Scribd company logo
1 of 18
Download to read offline
Database abstraction – GoogleApps Script
Desktop liberation
A massively scalable cloud based datastore
Usually used along with Google App Engine
APIs available for Python, Go, Java, Php
A JSONAPI exists
Has an SQL like query language (GQL)
GQL is query only
Only really supports flat level objects
Free daily quota can be eaten up fairly quickly
Many capabilities, fairly complex
It’s a database Jim, but not as we know it
There is no API for Google Apps Script
Have to use the JSON API, which is complex
and limited
Complex queries need pre-specified indexes
It’s conceptually different to normal
databases and structures
Oauth2 is mandatory
Database abstraction aims to simplify all that
With dbAbstraction, DataStore noSQL queries are the
same for all supported backends. So far this includes
Scriptdb
Parse.com
Fusion
Orchestrate.io
Fusion
Sheets
Import.io
Drive
Properties
DataStore
Your Script
cDataHandler
library
cEzyOauth2
library
cCacheHandler
library
Your webapp
App template
Your property
store
cDataStore
driver
Cloud
DataStore
cFlattener
library
noSQL queries
Access token
Google oauth2
infrastructure
Query caching
cNamedLock
library
Transaction locking
JSON API
Query translation
authentication
Cloud
credentials
Access & refresh tokens
(un)Flatten objects
The same as other database backends up to
the driver
Caching, locking and oAuth2 built in
Complex objects supported through
flattening with dot syntax
Complex queries handled by DataStore when
index exists
Non indexed queries automatically handled
by driver filtering
handler.query ( );
handler.query ({sex:”male”} );
handler.query ({sex:”male”,country:”USA”} );
handler.query ({sex:”male”,network:{google:{usage:”seldom”}}});
Handler.query({sex:”male”,”network.google.usage”:”seldom”});
Handler.query({sex:”female”,handler.constraint([[c.GT,50],[c.LT,6
0]])});
Handler.query({},{limit:20,sort:”-age”});
Handler.query({sex:”female”,
age:handler.constraint([[c.GT,50],[c.LT,60]] ,
name:handler.constraint([[c.IN,[”smith”,”jones”]] )},
{sort:”network.google.usage”});
handler.count ({sex:”male”} );
handler.remove ( );
handler.remove ({sex:”male”} );
handler.remove({query ({sex:”male”,country:”USA”} );
handler.remove({sex:”male”,network:{google:{usage:”seldo
m”}}});
Handler.remove({sex:”male”,”network.google.usage”:”seld
om”});
Handler.remove({sex:”female”,handler.constraint([[c.GT,50]
,[c.LT,60]])});
Handler.remove({},{limit:20,sort:”-age”});
handler.save({name:”john”,age:25,country:”USA”,network:{
google:”seldom”,facebook:”often”}} );
handler.save([{name:”john”,age:25,country:”USA”,network:
{google:”seldom”,facebook:”often”}},
name:”mary”,age:28,country:”UK”,network:{google:”ofte
n”,facebook:”never”}}]);
var result = handler.query
({network.google:”seldom”},undefined,1, true );
result.data.forEach(function(d) { d.target = true; });
handler.update (result.handleKeys, result.data);
var result = handler.query
({network.google:”often”},{sort:”age”,limit:10},1, true);
result.data.forEach(function(d) { d.target = true; });
handler.update (result.handleKeys, result.data);
var resultFromCache = handler.query
({network.google:”seldom”});
var resultNoCache = handler.query
({network.google:”seldom”,undefined, 1});
A standard recipe
function doGet (e) {
return doGetPattern(e, constructConsentScreen, doSomething, 'googleDatastore') ;
}
1. The name of a function that returns an html string with a user consent dialog. Will only get
called the first time doGet() is run to kick off the self maintaining access/refresh token
details
2. The name of a function that does what your doGet() would normally do, and returns what it
would normally return
3. A unique name against which to store the access/refresh token details in the property store
1 2 3
Your datastore credentials and scopes should be
stored in your properties store
EzyOauth2 will update your credentials object
with refresh and access token information
Every time after the first time run, your access
token will be refreshed automatically when
necessary
Functions are provided in the pattern for your
function to read and write properties, but the
libraries never access your properties directly.
The ongoing pattern is more or less the same
for both webapp and non-webapp
doGet() needs to be run at least once to
provoke an authorization dialog
Non- webapps need a doGet() function run
just once to get the refresh token
infrastructure set up.You can delete the
doGet() function after that.
Code is in the Patterns example, and looks like
this. Substitute your own credentials and run
function oneTimeSetProperties () {
setAuthenticationPackage_ ({
clientId : “xxx.apps.googleusercontent.com",
clientSecret : “xxx",
scopes :
['https://www.googleapis.com/auth/datastore','https://www.googleapis.com/a
uth/userinfo.email'],
service: 'google',
packageName: 'googleDatastore'
});
}
Substitute your credentials and run this , one time
function oneTimeSetProperties () {
setAuthenticationPackage_ ({
clientId : “xxx.apps.googleusercontent.com",
clientSecret : “xxx",
scopes : ['https://www.googleapis.com/auth/datastore','https://www.googleapis.com/auth
service: 'google',
packageName: 'googleDatastore'
});
}
This will get created
library key comments
cDataHandler Mj61W-
201_t_zC9fJg1IzYiz3TLx7pV4j
Abstracted interface to back end databases, and all
known drivers
cCacheHandler MXhfe1Z1GKU-_Qnd94LqcsKi_d-
phDA33
Manages caching of query results
cNamedLock MBaYiatjgCSvDcsG6fHIFsyz3TLx7p
V4j
Cross script locking of abstract resources
cEzyOauth2 MSaYlTXSVk7FAqpHNCcqBv6i_d-
phDA33
Manages oAuth2 credentials and offline refreshing of
access tokens
cFlatten MqxKdBrlw18FDd-
X5zQLd7yz3TLx7pV4j
Flattens complex objects to 1 level dot syntax objects so
they can be stored/queries in a 2 dimensional space
ezyOauth2 templates https://script.google.com/d/1ll5nvM
OZL5YODaj71l0-
XSaD0BBciG_zIV2I0Neu3Nz1LaKY6
-4WiJAt/edit?usp=sharing
Patterns for web and nonweb apps for easy oath2
authentication.Take a copy of this
Read about data abstraction using the
datastore here.
Read about ezyOauth2 here.
Contact me on google plus or at my forum
Join the Google Apps Script Community

More Related Content

What's hot

Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetDo something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetBruce McPherson
 
Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2Bruce McPherson
 
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your Data
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your DataMongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your Data
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your DataMongoDB
 
Do something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databasesDo something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databasesBruce McPherson
 
MongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineMongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineJason Terpko
 
Euruko 2009 - DataObjects
Euruko 2009 - DataObjectsEuruko 2009 - DataObjects
Euruko 2009 - DataObjectsDirkjan Bussink
 
Elasticsearch an overview
Elasticsearch   an overviewElasticsearch   an overview
Elasticsearch an overviewAmit Juneja
 
FleetDB: A Schema-Free Database in Clojure
FleetDB: A Schema-Free Database in ClojureFleetDB: A Schema-Free Database in Clojure
FleetDB: A Schema-Free Database in ClojureMark McGranaghan
 
Py spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.comPy spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.comLam Hoang
 
Building data flows with Celery and SQLAlchemy
Building data flows with Celery and SQLAlchemyBuilding data flows with Celery and SQLAlchemy
Building data flows with Celery and SQLAlchemyRoger Barnes
 
Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performanceYehuda Katz
 
PostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL SuperpowersPostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL SuperpowersAmanda Gilmore
 
Appengine Java Night #2b
Appengine Java Night #2bAppengine Java Night #2b
Appengine Java Night #2bShinichi Ogawa
 
Softshake - Offline applications
Softshake - Offline applicationsSoftshake - Offline applications
Softshake - Offline applicationsjeromevdl
 

What's hot (20)

Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetDo something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
 
Html indexed db
Html indexed dbHtml indexed db
Html indexed db
 
Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2
 
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your Data
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your DataMongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your Data
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your Data
 
Do something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databasesDo something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databases
 
MongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineMongoDB - Aggregation Pipeline
MongoDB - Aggregation Pipeline
 
Euruko 2009 - DataObjects
Euruko 2009 - DataObjectsEuruko 2009 - DataObjects
Euruko 2009 - DataObjects
 
Elasticsearch an overview
Elasticsearch   an overviewElasticsearch   an overview
Elasticsearch an overview
 
FleetDB: A Schema-Free Database in Clojure
FleetDB: A Schema-Free Database in ClojureFleetDB: A Schema-Free Database in Clojure
FleetDB: A Schema-Free Database in Clojure
 
Py spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.comPy spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.com
 
Building data flows with Celery and SQLAlchemy
Building data flows with Celery and SQLAlchemyBuilding data flows with Celery and SQLAlchemy
Building data flows with Celery and SQLAlchemy
 
Polyglot parallelism
Polyglot parallelismPolyglot parallelism
Polyglot parallelism
 
Html web sql database
Html web sql databaseHtml web sql database
Html web sql database
 
#ajn3.lt.marblejenka
#ajn3.lt.marblejenka#ajn3.lt.marblejenka
#ajn3.lt.marblejenka
 
Database c# connetion
Database c# connetionDatabase c# connetion
Database c# connetion
 
Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performance
 
PostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL SuperpowersPostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL Superpowers
 
Appengine Java Night #2b
Appengine Java Night #2bAppengine Java Night #2b
Appengine Java Night #2b
 
Softshake - Offline applications
Softshake - Offline applicationsSoftshake - Offline applications
Softshake - Offline applications
 
greenDAO
greenDAOgreenDAO
greenDAO
 

Viewers also liked

Viewers also liked (16)

Cloud sql datasheet
Cloud sql datasheetCloud sql datasheet
Cloud sql datasheet
 
Intellectual Intersections, draft program
Intellectual Intersections, draft programIntellectual Intersections, draft program
Intellectual Intersections, draft program
 
My Sql Performance In A Cloud
My Sql Performance In A CloudMy Sql Performance In A Cloud
My Sql Performance In A Cloud
 
Getting Started with Google Cloud Technology
Getting Started with Google Cloud TechnologyGetting Started with Google Cloud Technology
Getting Started with Google Cloud Technology
 
2011 july-gtug-high-replication-datastore
2011 july-gtug-high-replication-datastore2011 july-gtug-high-replication-datastore
2011 july-gtug-high-replication-datastore
 
Webapp2 2.2
Webapp2 2.2Webapp2 2.2
Webapp2 2.2
 
Data Migrations in the App Engine Datastore
Data Migrations in the App Engine DatastoreData Migrations in the App Engine Datastore
Data Migrations in the App Engine Datastore
 
AWS Webcast - Highly Available SQL Server on AWS
AWS Webcast - Highly Available SQL Server on AWS  AWS Webcast - Highly Available SQL Server on AWS
AWS Webcast - Highly Available SQL Server on AWS
 
Restful App Engine
Restful App EngineRestful App Engine
Restful App Engine
 
Scaling Galaxy on Google Cloud Platform
Scaling Galaxy on Google Cloud PlatformScaling Galaxy on Google Cloud Platform
Scaling Galaxy on Google Cloud Platform
 
SQL Server on Google Cloud Platform
SQL Server on Google Cloud PlatformSQL Server on Google Cloud Platform
SQL Server on Google Cloud Platform
 
google Bigtable
google Bigtablegoogle Bigtable
google Bigtable
 
工程師必備第一工具 - Git
工程師必備第一工具 - Git工程師必備第一工具 - Git
工程師必備第一工具 - Git
 
Google BigTable
Google BigTableGoogle BigTable
Google BigTable
 
Cloud computing simple ppt
Cloud computing simple pptCloud computing simple ppt
Cloud computing simple ppt
 
The Google Bigtable
The Google BigtableThe Google Bigtable
The Google Bigtable
 

Similar to Google cloud datastore driver for Google Apps Script DB abstraction

Google App Engine With Java And Groovy
Google App Engine With Java And GroovyGoogle App Engine With Java And Groovy
Google App Engine With Java And GroovyKen Kousen
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for JavaLars Vogel
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksThomas Fuchs
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Enginecatherinewall
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Tony Frame
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with PythonBrian Lyttle
 
The 90-Day Startup with Google AppEngine for Java
The 90-Day Startup with Google AppEngine for JavaThe 90-Day Startup with Google AppEngine for Java
The 90-Day Startup with Google AppEngine for JavaDavid Chandler
 
Nuxeo - OpenSocial
Nuxeo - OpenSocialNuxeo - OpenSocial
Nuxeo - OpenSocialThomas Roger
 
Academy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storageAcademy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storageBinary Studio
 
node.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoonnode.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang YoonJesang Yoon
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for JavaLars Vogel
 
Google app-engine-cloudcamplagos2011
Google app-engine-cloudcamplagos2011Google app-engine-cloudcamplagos2011
Google app-engine-cloudcamplagos2011Opevel
 
Hibernate jj
Hibernate jjHibernate jj
Hibernate jjJoe Jacob
 
Flask jwt authentication tutorial
Flask jwt authentication tutorialFlask jwt authentication tutorial
Flask jwt authentication tutorialKaty Slemon
 
Android application architecture
Android application architectureAndroid application architecture
Android application architectureRomain Rochegude
 
What is App Engine? O
What is App Engine? OWhat is App Engine? O
What is App Engine? Oikailan
 

Similar to Google cloud datastore driver for Google Apps Script DB abstraction (20)

Google App Engine With Java And Groovy
Google App Engine With Java And GroovyGoogle App Engine With Java And Groovy
Google App Engine With Java And Groovy
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-Frameworks
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with Python
 
The 90-Day Startup with Google AppEngine for Java
The 90-Day Startup with Google AppEngine for JavaThe 90-Day Startup with Google AppEngine for Java
The 90-Day Startup with Google AppEngine for Java
 
Meteor Angular
Meteor AngularMeteor Angular
Meteor Angular
 
Nuxeo - OpenSocial
Nuxeo - OpenSocialNuxeo - OpenSocial
Nuxeo - OpenSocial
 
Academy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storageAcademy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storage
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
node.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoonnode.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoon
 
Tomcat + other things
Tomcat + other thingsTomcat + other things
Tomcat + other things
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
 
Google app-engine-cloudcamplagos2011
Google app-engine-cloudcamplagos2011Google app-engine-cloudcamplagos2011
Google app-engine-cloudcamplagos2011
 
Hibernate jj
Hibernate jjHibernate jj
Hibernate jj
 
Flask jwt authentication tutorial
Flask jwt authentication tutorialFlask jwt authentication tutorial
Flask jwt authentication tutorial
 
Android application architecture
Android application architectureAndroid application architecture
Android application architecture
 
What is App Engine? O
What is App Engine? OWhat is App Engine? O
What is App Engine? O
 

More from Bruce McPherson

Do something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilterDo something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilterBruce McPherson
 
Do something in 5 with gas 7-email log
Do something in 5 with gas 7-email logDo something in 5 with gas 7-email log
Do something in 5 with gas 7-email logBruce McPherson
 
Do something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing appDo something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing appBruce McPherson
 
Do something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a databaseDo something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a databaseBruce McPherson
 
Do something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as databaseDo something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as databaseBruce McPherson
 
Javascript like objects and JSON processing in VBA
Javascript like objects and JSON processing in VBAJavascript like objects and JSON processing in VBA
Javascript like objects and JSON processing in VBABruce McPherson
 

More from Bruce McPherson (6)

Do something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilterDo something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilter
 
Do something in 5 with gas 7-email log
Do something in 5 with gas 7-email logDo something in 5 with gas 7-email log
Do something in 5 with gas 7-email log
 
Do something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing appDo something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing app
 
Do something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a databaseDo something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a database
 
Do something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as databaseDo something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as database
 
Javascript like objects and JSON processing in VBA
Javascript like objects and JSON processing in VBAJavascript like objects and JSON processing in VBA
Javascript like objects and JSON processing in VBA
 

Recently uploaded

Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Cathrine Wilhelmsen
 
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Boston Institute of Analytics
 
Decoding Patterns: Customer Churn Prediction Data Analysis Project
Decoding Patterns: Customer Churn Prediction Data Analysis ProjectDecoding Patterns: Customer Churn Prediction Data Analysis Project
Decoding Patterns: Customer Churn Prediction Data Analysis ProjectBoston Institute of Analytics
 
knowledge representation in artificial intelligence
knowledge representation in artificial intelligenceknowledge representation in artificial intelligence
knowledge representation in artificial intelligencePriyadharshiniG41
 
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdfEnglish-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdfblazblazml
 
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...boychatmate1
 
World Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdf
World Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdfWorld Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdf
World Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdfsimulationsindia
 
Digital Indonesia Report 2024 by We Are Social .pdf
Digital Indonesia Report 2024 by We Are Social .pdfDigital Indonesia Report 2024 by We Are Social .pdf
Digital Indonesia Report 2024 by We Are Social .pdfNicoChristianSunaryo
 
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxmodul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxaleedritatuxx
 
Digital Marketing Plan, how digital marketing works
Digital Marketing Plan, how digital marketing worksDigital Marketing Plan, how digital marketing works
Digital Marketing Plan, how digital marketing worksdeepakthakur548787
 
Non Text Magic Studio Magic Design for Presentations L&P.pdf
Non Text Magic Studio Magic Design for Presentations L&P.pdfNon Text Magic Studio Magic Design for Presentations L&P.pdf
Non Text Magic Studio Magic Design for Presentations L&P.pdfPratikPatil591646
 
Statistics For Management by Richard I. Levin 8ed.pdf
Statistics For Management by Richard I. Levin 8ed.pdfStatistics For Management by Richard I. Levin 8ed.pdf
Statistics For Management by Richard I. Levin 8ed.pdfnikeshsingh56
 
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...Boston Institute of Analytics
 
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis model
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis modelDecoding Movie Sentiments: Analyzing Reviews with Data Analysis model
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis modelBoston Institute of Analytics
 
Principles and Practices of Data Visualization
Principles and Practices of Data VisualizationPrinciples and Practices of Data Visualization
Principles and Practices of Data VisualizationKianJazayeri1
 
Bank Loan Approval Analysis: A Comprehensive Data Analysis Project
Bank Loan Approval Analysis: A Comprehensive Data Analysis ProjectBank Loan Approval Analysis: A Comprehensive Data Analysis Project
Bank Loan Approval Analysis: A Comprehensive Data Analysis ProjectBoston Institute of Analytics
 
IBEF report on the Insurance market in India
IBEF report on the Insurance market in IndiaIBEF report on the Insurance market in India
IBEF report on the Insurance market in IndiaManalVerma4
 
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024Susanna-Assunta Sansone
 

Recently uploaded (20)

Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)
 
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
 
Decoding Patterns: Customer Churn Prediction Data Analysis Project
Decoding Patterns: Customer Churn Prediction Data Analysis ProjectDecoding Patterns: Customer Churn Prediction Data Analysis Project
Decoding Patterns: Customer Churn Prediction Data Analysis Project
 
knowledge representation in artificial intelligence
knowledge representation in artificial intelligenceknowledge representation in artificial intelligence
knowledge representation in artificial intelligence
 
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdfEnglish-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
 
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
 
World Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdf
World Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdfWorld Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdf
World Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdf
 
Digital Indonesia Report 2024 by We Are Social .pdf
Digital Indonesia Report 2024 by We Are Social .pdfDigital Indonesia Report 2024 by We Are Social .pdf
Digital Indonesia Report 2024 by We Are Social .pdf
 
Data Analysis Project: Stroke Prediction
Data Analysis Project: Stroke PredictionData Analysis Project: Stroke Prediction
Data Analysis Project: Stroke Prediction
 
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxmodul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
 
Digital Marketing Plan, how digital marketing works
Digital Marketing Plan, how digital marketing worksDigital Marketing Plan, how digital marketing works
Digital Marketing Plan, how digital marketing works
 
Non Text Magic Studio Magic Design for Presentations L&P.pdf
Non Text Magic Studio Magic Design for Presentations L&P.pdfNon Text Magic Studio Magic Design for Presentations L&P.pdf
Non Text Magic Studio Magic Design for Presentations L&P.pdf
 
Statistics For Management by Richard I. Levin 8ed.pdf
Statistics For Management by Richard I. Levin 8ed.pdfStatistics For Management by Richard I. Levin 8ed.pdf
Statistics For Management by Richard I. Levin 8ed.pdf
 
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
 
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis model
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis modelDecoding Movie Sentiments: Analyzing Reviews with Data Analysis model
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis model
 
Principles and Practices of Data Visualization
Principles and Practices of Data VisualizationPrinciples and Practices of Data Visualization
Principles and Practices of Data Visualization
 
Bank Loan Approval Analysis: A Comprehensive Data Analysis Project
Bank Loan Approval Analysis: A Comprehensive Data Analysis ProjectBank Loan Approval Analysis: A Comprehensive Data Analysis Project
Bank Loan Approval Analysis: A Comprehensive Data Analysis Project
 
Insurance Churn Prediction Data Analysis Project
Insurance Churn Prediction Data Analysis ProjectInsurance Churn Prediction Data Analysis Project
Insurance Churn Prediction Data Analysis Project
 
IBEF report on the Insurance market in India
IBEF report on the Insurance market in IndiaIBEF report on the Insurance market in India
IBEF report on the Insurance market in India
 
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
 

Google cloud datastore driver for Google Apps Script DB abstraction

  • 1. Database abstraction – GoogleApps Script Desktop liberation
  • 2. A massively scalable cloud based datastore Usually used along with Google App Engine APIs available for Python, Go, Java, Php A JSONAPI exists Has an SQL like query language (GQL) GQL is query only Only really supports flat level objects Free daily quota can be eaten up fairly quickly Many capabilities, fairly complex It’s a database Jim, but not as we know it
  • 3. There is no API for Google Apps Script Have to use the JSON API, which is complex and limited Complex queries need pre-specified indexes It’s conceptually different to normal databases and structures Oauth2 is mandatory Database abstraction aims to simplify all that
  • 4. With dbAbstraction, DataStore noSQL queries are the same for all supported backends. So far this includes Scriptdb Parse.com Fusion Orchestrate.io Fusion Sheets Import.io Drive Properties DataStore
  • 5. Your Script cDataHandler library cEzyOauth2 library cCacheHandler library Your webapp App template Your property store cDataStore driver Cloud DataStore cFlattener library noSQL queries Access token Google oauth2 infrastructure Query caching cNamedLock library Transaction locking JSON API Query translation authentication Cloud credentials Access & refresh tokens (un)Flatten objects
  • 6. The same as other database backends up to the driver Caching, locking and oAuth2 built in Complex objects supported through flattening with dot syntax Complex queries handled by DataStore when index exists Non indexed queries automatically handled by driver filtering
  • 7. handler.query ( ); handler.query ({sex:”male”} ); handler.query ({sex:”male”,country:”USA”} ); handler.query ({sex:”male”,network:{google:{usage:”seldom”}}}); Handler.query({sex:”male”,”network.google.usage”:”seldom”}); Handler.query({sex:”female”,handler.constraint([[c.GT,50],[c.LT,6 0]])}); Handler.query({},{limit:20,sort:”-age”}); Handler.query({sex:”female”, age:handler.constraint([[c.GT,50],[c.LT,60]] , name:handler.constraint([[c.IN,[”smith”,”jones”]] )}, {sort:”network.google.usage”}); handler.count ({sex:”male”} );
  • 8. handler.remove ( ); handler.remove ({sex:”male”} ); handler.remove({query ({sex:”male”,country:”USA”} ); handler.remove({sex:”male”,network:{google:{usage:”seldo m”}}}); Handler.remove({sex:”male”,”network.google.usage”:”seld om”}); Handler.remove({sex:”female”,handler.constraint([[c.GT,50] ,[c.LT,60]])}); Handler.remove({},{limit:20,sort:”-age”});
  • 10. var result = handler.query ({network.google:”seldom”},undefined,1, true ); result.data.forEach(function(d) { d.target = true; }); handler.update (result.handleKeys, result.data); var result = handler.query ({network.google:”often”},{sort:”age”,limit:10},1, true); result.data.forEach(function(d) { d.target = true; }); handler.update (result.handleKeys, result.data);
  • 11. var resultFromCache = handler.query ({network.google:”seldom”}); var resultNoCache = handler.query ({network.google:”seldom”,undefined, 1});
  • 12. A standard recipe function doGet (e) { return doGetPattern(e, constructConsentScreen, doSomething, 'googleDatastore') ; } 1. The name of a function that returns an html string with a user consent dialog. Will only get called the first time doGet() is run to kick off the self maintaining access/refresh token details 2. The name of a function that does what your doGet() would normally do, and returns what it would normally return 3. A unique name against which to store the access/refresh token details in the property store 1 2 3
  • 13. Your datastore credentials and scopes should be stored in your properties store EzyOauth2 will update your credentials object with refresh and access token information Every time after the first time run, your access token will be refreshed automatically when necessary Functions are provided in the pattern for your function to read and write properties, but the libraries never access your properties directly.
  • 14. The ongoing pattern is more or less the same for both webapp and non-webapp doGet() needs to be run at least once to provoke an authorization dialog Non- webapps need a doGet() function run just once to get the refresh token infrastructure set up.You can delete the doGet() function after that.
  • 15. Code is in the Patterns example, and looks like this. Substitute your own credentials and run function oneTimeSetProperties () { setAuthenticationPackage_ ({ clientId : “xxx.apps.googleusercontent.com", clientSecret : “xxx", scopes : ['https://www.googleapis.com/auth/datastore','https://www.googleapis.com/a uth/userinfo.email'], service: 'google', packageName: 'googleDatastore' }); }
  • 16. Substitute your credentials and run this , one time function oneTimeSetProperties () { setAuthenticationPackage_ ({ clientId : “xxx.apps.googleusercontent.com", clientSecret : “xxx", scopes : ['https://www.googleapis.com/auth/datastore','https://www.googleapis.com/auth service: 'google', packageName: 'googleDatastore' }); } This will get created
  • 17. library key comments cDataHandler Mj61W- 201_t_zC9fJg1IzYiz3TLx7pV4j Abstracted interface to back end databases, and all known drivers cCacheHandler MXhfe1Z1GKU-_Qnd94LqcsKi_d- phDA33 Manages caching of query results cNamedLock MBaYiatjgCSvDcsG6fHIFsyz3TLx7p V4j Cross script locking of abstract resources cEzyOauth2 MSaYlTXSVk7FAqpHNCcqBv6i_d- phDA33 Manages oAuth2 credentials and offline refreshing of access tokens cFlatten MqxKdBrlw18FDd- X5zQLd7yz3TLx7pV4j Flattens complex objects to 1 level dot syntax objects so they can be stored/queries in a 2 dimensional space ezyOauth2 templates https://script.google.com/d/1ll5nvM OZL5YODaj71l0- XSaD0BBciG_zIV2I0Neu3Nz1LaKY6 -4WiJAt/edit?usp=sharing Patterns for web and nonweb apps for easy oath2 authentication.Take a copy of this
  • 18. Read about data abstraction using the datastore here. Read about ezyOauth2 here. Contact me on google plus or at my forum Join the Google Apps Script Community