
Translating SQL Queries using map, reduce, and filter in JavaScript - zsolt777
http://www.zsoltnagy.eu/translating-sql-queries-using-map-reduce-filter-in-javascript/
======
chadcmulligan
My Answer: To replace a SQL select with javascript map/reduce is senseless.
The whole idea of a database is to provide high performance access to data
using index lookups. This particular case can be performed by a full table
scan and a merge/sort operation, and so the performance might be acceptable,
that is not a general solution though.

As an aside: You could optimise this in sql by providing indices on some of
the fields and the DB would then perform a full index scan rather than a table
scan.

~~~
smadge
Additionally, SQL is a domain specific language that is standard and cross
platform. Why write a query dozens of different times for dozens of different
host languages when you could just write it once?

~~~
scarface74
In C# where you have something similar with Linq it makes sense. The runtime
translates Linq to expression trees and the Linq provider translates the
expression tree at runtime to a native query. That native query can be
anything - sql, mongoquery, or can be an in memory collection, etc.

You can use the same strongly typed Linq expression with anything.

~~~
smadge
I guess that’s true! Embedded domain specific languages could be useful to
swap out your data layer or provide a unified interface for different data
layers.

