Adds SQL-like query capabilities to JS Object Arrays.
Inclusion of the library adds where(), select() and orderBy() capabilities to object arrays.
- where() - Accepts SQL query string as parameter. Simulates SQL WHERE clause. Handles all expressions including BETWEEN and IN clauses. Scalars and Aggregate functions are not supported yet.
- select() - Simulates SQL SELECT.
- orderBy() - Simulates SQL ORDER BY.
- joinOn() - Simulates SQL INNER JOIN. (Experimental) Takes the join field (or the join expression) as the first parameter and the array to be joined as the next.
For testing, include sql-where.js in your project
###Example
var employee = [{
empid: 100,
ename: "Chuck"
}, {
empid: 101,
ename: "Rick"
}, {
empid: 99,
ename: "George"
}];
Calling
employee.where("ename like '%ck'").select("ename,empid").orderBy("empid desc")
returns [{ename:"Rick",empid:101},{ename:"Chuck",empid:100}]
.
###Future Add various SQL scalar and aggregate functions