March 16, 2013

Insights about ScriptDB


ScriptDB it's a great way to store and share JSON data for your Apps Script web apps! It's fast, free, flexible, and also provides plenty storage for most cases.

Let's start by pointing out ScriptDB's performance... inserting, updating and deleting data it's very fast and the time basically depends on the amount of objects we are working with regardless of the overall Database size, being consistent in performance from start and until you fill out your quota makes it suitable for many applications were other approach (like querying data from a large Spreadsheet) are just too slow.

ScriptDB does has a quota (limit), and it's set per user, so the quota space is shared by ALL your web apps. However, it is possible to connect to other user's ScriptDB by sharing Script DB libraries.

ScriptDB's query and storage it's quite flexible for storing and retrieving data from your DataBase. You find data by querying a specific subset of the JSON objects and it has methods that resembles the logical AND, OR and NOT, comparison operators and even facilitates sorting and pagination of the results, all this to allow you to adjust the output to your code's needs.

It also allows you to do the results iterations in many ways, and the one you choose mostly depends on your code's needs and your personal style. It has the  next() & hasnext() methods if you like using While loops or you can use the result.getSize() method if you prefer the For loops.

One last thing I'd like to mention about ScriptDB is it has something called "locks" which are used mostly for certain transactions were you don't want two instances running at the same time (to avoid over-writing) like in accumulators. There are two kinds of locks, public and private. In short, the difference is that public only allows 1 instance of the APP to run at any given time and the private lock only allows each USER to run 1 instance of the App at any given time.

Feel free to post your ideas, suggestions, requests, etc at the bottom of this article.

Happy coding!