big bad undefined variable

This commit is contained in:
Mark Nadal 2015-02-21 21:01:22 -07:00
parent 52ee2ec095
commit d5b7b61e4f
3 changed files with 35 additions and 3 deletions

4
gun.js
View File

@ -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.
});

View File

@ -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() }

32
web/notes-sql.txt Normal file
View File

@ -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" }
});