title: How to drop a database in postgres sql using node.js?
body: <p>I am trying to drop a database called <code>test</code> from node.js postgres sql but it is not working.</p>
  
  <pre><code>var express = require('express');
  var app = express();
  var pg = require('pg');
  var pgp = require('pg-promise')();
  
  // Connect to PostgreSQL database
  var connectionString = process.env.DATABASE_URL || 'postgres://postgres:pass123@localhost:5432/test';
  var db = pgp(connectionString);
  db.connect();
  
  
    db.query("DROP DATABASE test").then(function()
    {
      //createDatabases(db);
    }).catch(function(err)
    {
      console.log(err);
    });
  </code></pre>
  
  <p>But I am getting an error </p>
  
  <pre><code>{ [error: cannot drop the currently open database]
    name: 'error',
    length: 87,
    severity: 'ERROR',
    code: '55006',
    detail: undefined,
    hint: undefined,
    position: undefined,
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: undefined,
    table: undefined,
    column: undefined,
    dataType: undefined,
    constraint: undefined,
    file: 'dbcommands.c',
    line: '834',
    routine: 'dropdb' }
  </code></pre>
  
  <p>Does anyone know how to fix it?</p>
  
  <p>Thanks</p>