Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8479073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:55:26+00:00 2026-06-10T18:55:26+00:00

Code: var connection = mongoose.createConnection(‘mongodb://localhost:9000/’ + databaseName); connection.db.dropDatabase(function(err){ // never reach this point! debugger;

  • 0

Code:

var connection = mongoose.createConnection('mongodb://localhost:9000/' + databaseName);
connection.db.dropDatabase(function(err){
    // never reach this point!
    debugger;
    console.log(err);
    console.log('-------------->Dropped database: ' + databaseName);
});

If I do connection.open it says that it’s already opening and no multiple calls to “open” are supported for the same connection.

Even this doesn’t work

var conn = mongoose.createConnection('mongodb://localhost',databaseName, 9000, {}, function(){
    console.log('created'); // is reached
    conn.db.dropDatabase(callback); // but the callback is not called anyway
});

What is the problem? (“mongoose”: “3.1.0”)
The database is not even dropped…
thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:55:27+00:00Added an answer on June 10, 2026 at 6:55 pm
        var connection = mongoose.createConnection('mongodb://localhost:9000/' + databaseName, function(err){
            connection.db.dropDatabase(function(err){
                             // now it works!
                        })
        });
    

    The problem is that the dropDatabase command was not queued and not run when the connection opened. So if I used a callback on the createConnection then it worked and drop the db after this, it worked!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using this code for mysql connection $con = mysql_connect(localhost:/var/lib/mysql/mysql.sock, abc , xyz); if
In my socket.io code, socket.sockets.on('connection', function(client){ var ip = client.handshake.address.address; .. } ip always
Example code: var connection = null; function onConnect(status) { im_a_big_error.log('wtf'); // Why it doesn't
First of all, here's my code: var users = {}; //User Connect io.sockets.on('connection', function
I have following code. var mysql = require('mysql'); var connection = mysql.createConnection({ host :
current code I've built function to do something over collection of jQuery elements: var
I have the following code: var entityConnection = (System.Data.EntityClient.EntityConnection)c.Connection; DbConnection conn = entityConnection.StoreConnection; ConnectionState
I usually use code like this: using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings[MyConn].ConnectionString)) { var
I'm reading an Excel file with OLDB Connection using this code var connectionString =
I have this JS code: var recipesPost = function(name, ingredients, steps) { $.post('/api/recipes', {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.