I released 0.2.9 it adds SQL-like features:
- Join (inner only)
- Select
- Where (already been in it but an overload was added)
- Update
Now you can do this:
// updating the coins of player named "Radnen":
Link(players).where('name', 'Radnen').update('coins', 15);
// a separated inventory table and player table getting player radnen's items:
var items = Link(players).where('name', 'Radnen').join(items, function(a, b) { a.name == b.name; }).select('name', 'items').toArray();
// retrieving only certain "columns" from a table:
var stats = Link(players).select('name', 'speed', 'strength', 'wisdom').toArray();
This is *not* an SQL implementation. It is rather SQL-like functionality built into Link. When you form queries you form them almost backwards than what you'd expect from actual SQL: you do your "selects" last and "wheres" first.
How is it *like* SQL you may ask? Well if you picture the rows as array entries and columns as object properties then you have basically the shim needed to do basic SQL-like transforms on the data. The 'players' table from above may look like this:
var players = [
{name: "Radnen" , coins: 0 , strength: 1, wisdom: 10, speed: 5},
{name: "DaVince", coins: 20 , strength: 2, wisdom: 12, speed: 4},
{name: "Jest" , coins: 100, strength: 1, wisdom: 11, speed: 6}];
And the items table could look like this:
var items = [
{name: "Radnen" , items: ["helmet"]},
{name: "DaVince", items: ["bag", "jeans"]},
{name: "Jest" , items: ["staff", "outfit"]}];
Join and select would work exactly as you would expect and update will modify the list.