As far as I know, most relational databases do not offer any driver-level API for queries, except a query
function which takes an SQL string as an argument.
I'm thinking how easier it would be if one could do:
var result = mysql.select('article', {id: 3})
For joined tables, it would be slightly more complex, but still possible. For example:
var tables = mysql.join({tables: ['article', 'category'], on: 'categoryID'});
mysql.select(tables, {'article.id': 3}, ['article.title', 'article.body', 'category.categoryID'])
Cleaner code, no string parsing overhead, no injection problems, easier reuse of query elements... I can see a lot of advantages.
Is there a specific reason why it was chosen to only provide access to queries through SQL?