I have created mongodb user with command
use admin db.createUser( { user: \"superuser\", pwd: \"12345678\", roles: [ \"root\" ] } )
Correct way to create the connection string is var connection = mongoose.createConnection("mongodb://username:pwd@hostip:port/dbname?authSource=admin", options);
Please use authSource=admin to authenticate in connection string.