diff --git a/gun.js b/gun.js index f4b17207..6244d63f 100644 --- a/gun.js +++ b/gun.js @@ -328,8 +328,8 @@ cb = cb || function(){}; // fail safe our function. (function trace(){ // create a recursive function, and immediately call it. gun._.field = Gun.text.ify(path.shift()); // where are we at? Figure it out. - if(gun._.node && path.length && Gun.is.soul(gun._.node[gun._.field])){ // if we need to recurse more - return gun.load(val, function(err){ // and the recursion happens to be on a relation, then load it. + if(gun._.node && path.length && (cb.soul = Gun.is.soul(gun._.node[gun._.field]))) { // if we need to recurse more + return gun.load(cb.soul, function(err){ // and the recursion happens to be on a relation, then load it. if(err){ return cb.call(gun, err) } trace(gun._ = this._); // follow the context down the chain. }); diff --git a/lib/http.js b/lib/http.js index e7dc1eb4..af7fd024 100644 --- a/lib/http.js +++ b/lib/http.js @@ -2,7 +2,7 @@ var Gun = require('../gun') , formidable = require('formidable') , url = require('url'); module.exports = function(req, res, next){ - next = next || function(){}; + next = next || function(){}; // if not next, and we don't handle it, we should res.end if(!req || !res){ return next() } if(!req.url){ return next() } if(!req.method){ return next() } diff --git a/web/notes-sql.txt b/web/notes-sql.txt new file mode 100644 index 00000000..3c366ad2 --- /dev/null +++ b/web/notes-sql.txt @@ -0,0 +1,32 @@ +OrderID CustomerID OrderDate +10308 2 1996-09-18 +10309 37 1996-09-19 +10310 77 1996-09-20 + +CustomerID CustomerName ContactName Country +1 Alfreds Futterkiste Maria Anders Germany +2 Ana Trujillo Emparedados y helados Ana Trujillo Mexico +3 Antonio Moreno Taquería Antonio Moreno Mexico + +{ + Orders: { + 10308: {OrderID: 10308, Customer: {#: 2}, OrderDate: '1996-09-18' } + 10309: {OrderID: 10309, Customer: {#: 3}, OrderDate: '1996-09-19' } + 10310: {OrderID: 10310, Customer: {#: 77}, OrderDate: '1996-09-20' } + } + Customers: { + 1: {CustomerID: 1, CustomerName: "Alfreds Futterkiste", ContactName: "Maria Anders", Country: "Germany" } + 2: {CustomerID: 2, CustomerName: "Ana Trujillo Emparedados y helados", ContactName: "Ana Trujillo", Country: "Mexico" } + 3: {CustomerID: 3, CustomerName: "Antonio Moreno Taquería", ContactName: "Antonio Moreno", Country: "Mexico" } + } +} + +gun.sql().select('OrderID', 'Customers.CustomerName', 'OrderDate').from('Orders').join('Cutomers').on('Customer'); // ignore /\s*=/ig and beyond + +^compatibility. // select should accept 1 string that is /\,\s*/ig separated, arguments of strings, an array of strings. +// unfortunately for compatibility mode, you might have to match&strip any string that has a '.' in it with a subsequent .join/.on +better: + +gun.sql().select('OrderID', OrderDate').from('Orders').join.on('Customer').select('CustomerName').run().get(function(row){ + console.log(row); // {OrderID: 10308, CustomerName: "Ana Trujillo Emparedados y helados", OrderDate: "1996-09-18" } +}); \ No newline at end of file