0

Is it possible to drop a mongodb database from my app’s api?

I can do it using mongosh, db.dropDatabase(), but would like to do this from my JavaScript api. I can’t seem to find much info, or perhaps in my naivety I’m searching for the right term.

Any help would be appreciated,

Cheers

  • Please add your app code. I'll try to guess, if your app uses mongoose you can do `await mongoose.connection.dropDatabase();` – Pavel Bely Aug 23 '23 at 14:11
  • Thanks @PavelBely, that worked. Cannot figure out why I found the dropDatabase in mongoose. Apologies for not adding code, there wasn’t any as yet as I was trying to figure what it was I needed – codeButcher Aug 23 '23 at 14:44
  • no worries, glad to hear it helped – Pavel Bely Aug 23 '23 at 14:46
  • Does this answer your question? [How to drop a database with Mongoose?](https://stackoverflow.com/questions/10081452/how-to-drop-a-database-with-mongoose) – Pavel Bely Aug 23 '23 at 14:47
  • Please provide enough code so others can better understand or reproduce the problem. – Community Aug 23 '23 at 23:03

0 Answers0