wipe a mongo collection - 06-29-20
Currently I run a shared mongo instance in my k8s cluster used by a bunch of my side projects. Every once in a while I have to manually execute mongo commands this is how I do so.
Manually ssh into the pod:
$ kubectl exec -it shared-mongo-xxxxxxxxxx-xxxxx -- /bin/bash
Then launch the mongo shell and hack away:
$ mongo
> db2 = db.getSiblingDB('coolDB')
coolDB
> db2.getCollectionNames()
[ "coolThings" ]
> db2.coolThings.count()
666
> db2.coolThings.remove({})
WriteResult({ "nRemoved" : 666 })
> db2.coolThings.count()
0
source:
\- [
mongo
]