Playing around with the new Google Apps ScriptDB

I’m taking a break from d3.js and playing around with the new Apps Script DB. Those of you who read these posts or follow the rambling site may know that I have been building up a library of classes, modules and procedures that have equivalents in both Google Apps Script and Excel.

So what shall we do with ScriptDB? Well it gives us noSQL persistent storage associated with a Google Apps Script project. There are two main things I understood.

  • There are no separate tables. You break your data into ‘silos’ using some data type item
  • The database is associated with a project. I scratched my head for a bit when I found out that if you are using a library (which I am), then you can actually make the DB a persistent data store for your shared library – as opposed to the user project which calls it.
The rest library is a perfect candidate for this – currently I set it up as a module, but let’s see if I can use ScriptDB to store the library, and make it available to all users (Excel or GAS).
The first step is to deal with is this slightly annoying silo thing. I am going to store other things in this ScriptDB so I’ll create a silo Manager. You can find this class in the GAS mcpher shared library – I’ll get round to documenting it and writing it up in a later post, but in principle, you access the ScriptDB like this

 

and all the nastiness to do with siloing the data is taken care of through whatever key you choose for your silo. The restLibrary  is a cJobject  that today is created in code. In the future it will be maintained in the scriptDB, but i need a one off to initially populating the scriptDB. Here’s how -( yes it’s a one-liner)

 

Now that the library has been saved in the scriptDB (in a silo called restLibrary), I will need a way of accessing it with a future version of the rest Library module. I’ll use a function called getRestLibrary() that looks like this (another one liner)

 

 These libraries are available as per this post on managing shared GAS libraries <(my shared libraries can be accessed using key

MEQ3tE5y5_cTOAgUbUKSIAiz3TLx7pV4j

About brucemcp 223 Articles
I am a Google Developer Expert and decided to investigate Google Apps Script in my spare time. The more I investigated the more content I created so this site is extremely rich. Now, in 2019, a lot of things have disappeared or don’t work anymore due to Google having retired some stuff. I am however leaving things as is and where I came across some deprecated stuff, I have indicated it. I decided to write a book about it and to also create videos to teach developers who want to learn Google Apps Script. If you find the material contained in this site useful, you can support me by buying my books and or videos.

1 Comment

Leave a Reply

Your email address will not be published.


*


9 + 6 =