Created
June 6, 2014 17:43
-
-
Save aj07mm/0b7395f30549610c0073 to your computer and use it in GitHub Desktop.
Problema com closures!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require("assert") | |
var mongo = require('./mongo.js') | |
var databaseUrl = "leitordecarga"; | |
var collections = ["tables"] | |
var db = require("mongojs").connect(databaseUrl, collections); | |
callback = []; | |
db.open(function(err, db) { | |
if (!err) { | |
console.log("db opened!"); | |
}else { | |
console.log(err); | |
} | |
db.collection('tables', function(err, collection) { | |
collection.find({}, function(err, cursor) { | |
cursor.each(function(err, item){ | |
callback.push(item); | |
}); | |
}); | |
}); | |
}); | |
describe('array_to_tree', function(){ | |
describe('transform array to tree structure', function(){ | |
it('array com um elemento', function(){ | |
assert.equal(mongo.array_to_tree(1),1);<------como ter acesso ao array callback aqui??? | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment