Answer the question
In order to leave comments, you need to log in
Why does the node.js error occur again?
here is the code
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 ] }
if I change itfunction 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);
}
what am I doing wrong
Answer the question
In order to leave comments, you need to log in
gives such an errorThis is not an error, but the correct operation of the call
console.log(arguments);
. The fact that the first argument is null just means that there is no error.if I change itThe above code is identical to what is already in the example. What is changing?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question