AlaSQL in Action: The JavaScript SQL Database

AlaSQL in Action: The JavaScript SQL Database

Overview on AlaSQL, the popular lightweight client-side in memory SQL database, including a real life example of AlaSQL in action. I was surprised to see that there aren’t more posts about this popular lightweight client-side in-memory SQL database online apart from this awesome article I found.

What’s AlaSQL?

For starters, this open-source project garners 11k weekly downloads off npm and has over 5K stars on GitHub.

I was surprised to see that there aren’t more posts about this popular lightweight client-side in-memory SQL database online apart from this awesome article I found. However, AlaSQL’s website gets straight to the point:

  • JavaScript SQL database for browser and Node.js.
  • Handles both traditional relational tables and nested JSON data (NoSQL).
  • Export, store, and import data from localStorage, IndexedDB, or Excel.

What’s not to love? AlaSQL was designed to work in browser and Node.js, is fast, and super easy to use. Some say that when you need to find data fast and want a better alternative to a full database or Redis, check out AlaSQL.

We Love AlaSQL, too!

HarperDB has had the pleasure of using AlaSQL for its backend SQL functionality. We chose to use AlaSQL because it has extensive language support, is well supported and extensible, can execute SQL against data sets (JSON or Arrays), and the ability to generate reusable functions. AlaSQL enables us to convert SQL language into an Abstract Syntax Tree (AST) that we can programmatically interpret into our data model. We can feed data into a processor that can perform the calculations native to SQL, using the functions defined in the library throughout our project as APIs and not just in the context of a SQL call.

AlaSQL is extensible and allows us to create custom functions. For example, we created a custom function called SEARCH_JSON that allows HarperDB users to search and transform nested documents. This function wraps a popular npm package called JSONata. With AlaSQL we were able to embed another open-source package as a simple function call. Our implementation was as easy as defining the function (Note this is sample code):



const jsonata = require('jsonata');




 * wrapper function that implements the JSONata library, which performs searches, transforms, etc... on JSON


 * @param {String} jsonata_expression - the JSONata expression to execute


 * @param {any} data - data which will be evaluated


 * @returns {any}




function searchJSON(jsonata_expression, data){


    if(typeof jsonata_expression !== 'string' || jsonata_expression.length === 0){


        throw new Error('search json expression must be a non-empty string');



12 13

    let alias = '__' + jsonata_expression + '__';

14 15



        this.__ala__.res = {};



18 19

    if(hdb_utils.isEmpty(this.__ala__.res[alias])) {


        let expression = jsonata(jsonata_expression);


        this.__ala__.res[alias] = expression;




    return this.__ala__.res[alias].evaluate(data);




//Then define a custom function in AlaSQL:


const alasql = require('alasql');


alasql.fn.search_json = alasql.fn.SEARCH_JSON = searchJSON;

We are happy with our decision to use AlaSQL to interpret SQL into our data model and run performant queries against as much SQL as possible. That’s why we hosted the creators of AlaSQL on June 16th for a showcase to get an inside look at how AlaSQL was created, how it grew in popularity, and real-world use cases and products. It was awesome to hear from AlaSQL creators Mathias Rangel Wulff and Andrey Gershun. After Q&A on AlaSQL, our CTO Kyle Bernhardy shared more about using AlaSQL as HarperDB’s engine to interpret and parse complex SQL into our data model and perform simple to complex SQL CRUD operations, as well as exposing other libraries like Turf.js, JSONata and more.

Looking for more resources on this innovative client-side in-memory SQL database? Check out this JavaScript library designed for:

  • Fast in-memory SQL data processing for BI and ERP applications on fat clients
  • Easy ETL and options for persistence by data import/manipulation/export of several formats
  • All major browsers, Node.js, and mobile applications

database sql databases sql (structured query language) database applications code activation sql aggregation

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

3 Tips to Write SQL Queries That Are Easier to Read and Modify

3 practice tips to write SQL queries which are easier to read and modify even after six month and one year. Use this tips to write professional quality SQL.There is no doubt that writing code is more art than science and every coder cannot write beautiful code which is both readable and maintainable, even with the experience.

Backup Database using T-SQL Statements

Introduction In this article, We will discuss how to backup our database in MS-SQL Server using T-SQL Statements. We need to use BACKUP DATABASE statement to create full database backup, along with…

Welcome Back the T-SQL Debugger with SQL Complete – SQL Debugger

Debug SQL stored procedures and develop your SQL database project with dbForge SQL Complete, a new add-in for Visual Studio and SSMS. When you develop large chunks of T-SQL code with the help of the SQL Server Management Studio tool, it is essential to test the “Live” behavior of your code by making sure that each small piece of code works fine and being able to allocate any error message that may cause a failure within that code.

Learn to Build SQL Query| Ultimate SQL and DataBase Concepts|Simpliv

Learn to Build SQL Query| Ultimate SQL and DataBase Concepts