вот код
var mongoose = require("./libs/mongoose");
var User = require("./models/user").User;
var asyng = require('async');
asyng.series([
open,
dropDatabase,
createUsers,
close
],function (err,results) {
if(err) throw err;
console.log(arguments);
});
function open(callback) {
mongoose.connection.on('open',callback);
}
function dropDatabase(callback) {
var db = mongoose.connection.db;
db.dropDatabase(callback);
}
function createUsers(callback) {
asyng.parallel([
function (callback) {
var vasya = new User({username:'Вася',password: 'supervasay'});
vasya.save(function(err){
callback(err,vasya);
})
},
function (callback) {
var petya = new User({username:'Петя',password: 'superpetya'});
petya.save(function(err){
callback(err,petya);
})
},
function (callback) {
var admin = new User({username:'admin',password: 'superadmin'});
admin.save(function(err){
callback(err,admin);
})
}],callback);
}
function close(callback) {
mongoose.disconnect(callback);
}
выдает такую ошибку
{ '0': null,
'1': [ undefined, true, [ [Object], [Object], [Object] ], undefined ] }
если меняю так
function dropDatabase(err, callback) {
if(err) throw err;
var db = mongoose.connection.db;
db.dropDatabase(callback);
}
получаю так
undefined
/var/www/html/chatnode/node_modules/mongoose/node_modules/mongodb/lib/server.js:309
process.nextTick(function() { throw err; })
^
function () {
var args = arguments,
index = -1,
length = nativeMax(args.length - start, 0),
array = Array(length);
while (++index < length) {
array[index] = args[start + index];
}
switch (start) {
case 0: return func.call(this, array);
case 1: return func.call(this, args[0], array);
case 2: return func.call(this, args[0], args[1], array);
}
var otherArgs = Array(start + 1);
index = -1;
while (++index < start) {
otherArgs[index] = args[index];
}
otherArgs[start] = array;
return apply(func, this, otherArgs);
}
что я делаю не так