1

All I could find over the internet for this is mostly suggesting

  1. db.disableFreeMonitoring() - which is a admin database monitoring control

  2. db.collection.remove() - but this deletes all the documents (of course based on the filter provided as well) and

  3. db.collection.drop() - which deletes all the documents and indexes as an optimized approach over removing all.

Is there a way, I can keep the collection or database intact but at the same time disable any connection/query to lookup data from it? (I am coming from the point where disable and enable are commands in HBase actually.)

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Naman
  • 27,789
  • 26
  • 218
  • 353
  • [Is it possible to detach some specific database from MongoDB Server?](https://dba.stackexchange.com/questions/266468/is-it-possible-to-detach-some-specific-database-from-mongodb-server). – prasad_ May 11 '20 at 03:49
  • 2
    I don't think a collection can be disabled, but you might use [renameCollection](https://docs.mongodb.com/manual/reference/command/renameCollection/index.html#renamecollection) to obfuscate it. – Joe May 11 '20 at 07:36
  • @prasad_ RAM consumption is not my primary concern, access control is..practically - I want to delete, but before that disable to see if **any** of my underlying service might get impacted. In which case I could just enable back. I understand drop with backup and restore is a workaround, but both time and disk(movement) consuming. – Naman May 11 '20 at 09:57
  • @Joe Interesting suggestion indeed. Should be quick to rename a database.. but then https://stackoverflow.com/questions/9201832/how-do-you-rename-a-mongodb-database !! :| – Naman May 11 '20 at 10:00
  • @Joe I would suggest you make an answer to this. For now, all I could do with was perform a `getCollections` and iterate over each to rename them all. – Naman May 14 '20 at 06:20

0 Answers0