tryurl(3, function (err, id) { if (err) { return fn(err); } else if (id) { return fn(null, id); } else { // no id found mysql.generateBinId(length, attempts + 1, fn); } });
this.connection.query(templates.binExists, [id], function (err, results) { if (err) { fn(err); } else if (results.length) { attempts += 1; mysql.generateBinId(fn, attempts); } else { fn(null, id); } });