Skip to content

Instantly share code, notes, and snippets.

@aj07mm
Created June 6, 2014 17:43
Show Gist options
  • Save aj07mm/0b7395f30549610c0073 to your computer and use it in GitHub Desktop.
Save aj07mm/0b7395f30549610c0073 to your computer and use it in GitHub Desktop.
Problema com closures!
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