Database Methods: Drop Database

Deleting a database.

🪶 Removes
  • the current database, deleting the associated data files.

    Be aware that this method is irreversible and once deleted, you can no longer recover the deleted database!

    1
  • import
  • MerlinDB
  • from
  • "@chrisaxxwell/merlin-db";
    2
  • //Or if you are using 'merlindb.min.js' just call 'new MerlinDB()';
  • 3
    4
  • const
  • merlin =
  • new
  • MerlinDB(
  • )
  • ;  
    5merlin
  • .dropDatabase(
  • "YOUR-DATABASE-NAME"
  • )
  • ;
    6
    7
  • //e.g.
  • 8merlin
  • .dropDatabase(
  • "Movies"
  • )
  • .then(
  • e =>
  • {
  • 9   console
  • .log(
  • e
  • )
  • ;
    10  
  • //{status: 200, message: 'Database deleted successfully'}
  • 11  
    12
  • }
  • )
  • .catch(
  • e =>
  • {
  • 13   console
  • .log(
  • e
  • )
  • 14  
  • //{status: 400, message: "There's no 'YOUR-DATABASE-NAME' database!"}
  • 15
  • }
  • )
  • ;