DOMQL DOM Query Language: Web development for DBAsSerbo-Croatian translation
Lately its getting more and more obvious that web development is indeed a basic human right. And it should be accessible to every developer in the industry. jQuery played its part by making web development easier for designers, CoffeeScript for Rubyists and Pythonistas, Dart for Java devs, ClojureScript for Lispers etc.
But what about DBAs? aren't they equally human? Should they be doomed to suffer learning all about JS and the DOM?
DOMQL is here to make web development familiar to DBAs looking for a change of career (or suffering brain-damage). With a goal of making them Feel Right At Home™.
DOMQL is not a fully-fledged programming language but a small DSL inspired by SQL aimed at easing DOM manipulation for DBAs. Quick examples to make you feel warm and fuzzy (Feel Right At Home™):
SELECT DIV FROM BODY WHERE ID='container'
UPDATE (SELECT H1 FROM (SELECT DIV FROM BODY).ALL) SET CLASS='active' WHERE CLASS='disabled'
DELETE A FROM BODY.ALL WHERE HREF LIKE "google.com" AND ROWNUM BETWEEN 5 AND 10You had me at SELECT where is the freakin' download link? Download
Feel Right At Home™
Just as in transactional DBMS you can write queries that are insanely slow.
I tried my best to bring the stuff you most adore from SQL and I thought that Injections are a must have to make you Feel Right At Home™.
Features added/removed to make injections possible:
- Insert `--` anywhere in the code to comment out the rest of the query.
- Stacking queries. You can terminate any query with `;` and start a new one.
- Nothing is sanitized.
DOMQL("SELECT * FROM BODY WHERE CLASS='%s' AND ROWNUM > 2", "';DROP ELEMENT BODY;-- pwned! \o/")
Just like the TODO app example above you can embed your queries inside a script element with
and these queries would be run as soon as the page loads. The following would add 2 divs to the body element with ids header and container respectively:
<script type="text/domql"> INSERT INTO BODY VALUES ( CREATE ELEMENT DIV ( id 'header' ), CREATE ELEMENT DIV ( id 'container' ) ) </script>
Alternatively you could embed queries as templates using
text/domql-tmpl script type. You could think of them as stored procedures.
Templates would then be accessible from anywhere in your app using
DOMQL.tmpl('tmpl-id'). The function could also be passed
multiple arguments in a
<script type="text/domql-tmpl" id="hello-user"> CREATE ELEMENT SPAN ( class 'greetings', innerText 'Hello %s' ) </script>
Executes an embedded query template.
DOMQL() function passing it your query and any number of arguments (just like
DOMQL("UPDATE BODY SET style ='background:%s'", "red");
Takes a JS function and executes it when the DOM is ready for manipulation.
SELECT [Optional function ex:
COUNT(][html tags separated by a comma]
FROM [a single html tag or a Query between parentheses] followed by optional where clause:
WHERE [Expression: HTML Attribute or
OR [Other expression]...
UPDATE [a single html tag or a Query between parentheses]
SET [single or multiple key = value separated by a comma] followed by an optional where clause.
DELETE [html tags separated by commas]
FROM [a single html tag or a Query between parentheses] followed by an optional where clause.
INSERT INTO [a single html tag or a Query between parentheses]
VALUES ( [A single Query or multiple queries separated by commas]
CREATE ELEMENT [a single html tag]
( [zero, one or multiple key value separated by commas]
DROP ELEMENT [a single html tag or a Query between parentheses]