📜 ⬆️ ⬇️

TaffyDB - DBMS for AJAX Applications


If you are a developer of AJAX applications or interfaces, then you will find this useful. If you have to store some sufficiently large data in a structured way on the client side, how is it best done? Of course, ordinary arrays can help you (data type or, rather, the built-in Array object), and it will even provide basic functions for managing the data array and basic operations on it, but this is a very low level solution, some of the functionality may depend on JS engine implementation in a specific browser. In addition, to do something with the saved data you need to write a lot of your own code, and in the end your code turns into such a jumble of calls, functions and variables that it’s difficult to understand this.

Yes, there is a way out of this. In particular, the best solution (in theory) is to use special plugins to extend the functionality of the browser, for example, a full-fledged DBMS (SQLite) is built into Google Gears , and you get all of its capabilities right in your JavaScript code (the most valuable, In my view, besides storing large amounts of data, is full-text search). Similar tools can be found in the HTML 5 specification, and even in the latest versions of Mozilla Firefox, the database will be built in as a client storage system, and Adobe AIR also uses the built-in SQLite database. But what to do if all these joys are unavailable for any reason or their use is limited, and convenient storage and work with data must be available here and now, and without additional add-ons. There is a way out, of course!


All this is implemented in the Taffy DB project - a small (honestly, really very small, about 10 Kb) library that implements an almost full-fledged database entirely in JavaScript. It is intended, as I think, is already clear, for storing any type of data (including objects transmitted in the form of JSON), provides the CRUD paradigm ( more details in Wikipedia ), which allows the library to be classified as specialized databases, and also provides advanced search functions, filtering and sorting data. Taffy DB significantly expands the list of available operations on data collections, simplifies data insertion, sampling, update and deletion, supports sorting in various formats (traditional for DESC / ASC, including several fields at once), data sampling using various expressions ( almost as in ordinary SQL queries), taking into account equality, more / less, similarity with the sample, start / end of a line according to a given mask, and others. All operations are specified in the form of a JSON object (or rather, in the form of a JavaScript object written in JSON notation, but you understand).
')
It is stated that the library is compatible with all popular frameworks, including Dojo , ExtJS , Prototype , jQuery and others, while it is completely independent, without using other libraries for work. By the way, there is a module in Dojo that seems to have similar functionality, even a few (although they are not combined) - for SQL queries and for storing data in the form of collections and lists, in ExtJS , my favorite, there is a very good MixedCollection object that can It is much easier to work with data in the application, if you use ExtJS, but all of them are still, although they are a significant extension of the standard Array object, but they don’t fit the functionality of Taffy DB, which is “almost DB”.

And here an interesting perspective emerges. If Google Gears / HTML5 Storages and other technologies offer off-line storage, which data can be stored even after the page is closed and the browser is restarted, then these objects can only store objects while the application is running. But what if you write some layer, which, from above, will provide the entire API of the same Taffy or ExtJS.MixedCollection, well, inside it all ultimately works either through Dojo.storages (suggests using either Flash Storages or GoogleGears), either directly with any plugin. Of course, providing work even without these add-ins. For many applications, this would be very convenient and would allow creating serious web applications.

Try using Taffy DB in your projects, I'm sure you will appreciate its power, simplicity and speed. I already use, and you?

PS I decided to reprint the material from my blog with some amendments. The original is here .

Source: https://habr.com/ru/post/24126/


All Articles