AlaSQL — a query language for JavaScript

Why use it?

AlaSQL Quick Start Cheat Sheet

Question mark (?):

alasql(‘query ? goes here ?’, [thisDataRepresentsFirst?, thisDataRepresentsSecond?]);

Create a table:

alasql(‘CREATE TABLE tableName’);

Create one record:

alasql(‘INSERT INTO tableName VALUES ?’, [itemToInsert]);

Find a record:

alasql(‘SELECT EXISTS(SELECT * FROM ? WHERE arrlen(leechers) < 3 AND socketId in @(?)) AS hasCap’, [nodeTracker, broadcasterIds]);

Edit a record:

alasql(‘UPDATE tableName SET keyToUpdate = ? WHERE keyIdentifier = ?’, [valueThatKeyShouldBeUpdatedTo, valueOfKeyIdentifier]);

Delete a record:

alasql(‘DELETE FROM tableName WHERE keyToMatch = ?’, [“valueOfKeyToMatch”]);

Create a custom function:

alasql.fn.arrlen = function(arr) { return arr.length; };
alasql(‘VALUE OF SELECT socketId FROM nodeTracker WHERE arrlen(leechers) < 3 and socketId IN @(?)’, [broadcasterIds]);




Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dana Tran

Dana Tran

More from Medium

Joined select with ‘knex’

Best Practises I learned from SonarQube

OAuth 2.0 with Passport.js Part — 2

How to connect to a MySQL database with C# and WinForms.