Skip to content

Instantly share code, notes, and snippets.

@sarjarapu
Last active May 16, 2018 14:38
Show Gist options
  • Save sarjarapu/89888cc5c2a5830669e16f2548fb6501 to your computer and use it in GitHub Desktop.
Save sarjarapu/89888cc5c2a5830669e16f2548fb6501 to your computer and use it in GitHub Desktop.
Set of bash & JavaScript to show that user with readWrite role can drop a collection
mongo social --port 28000 -u app_user -p password --authenticationDatabase admin
# output of above command
# MongoDB shell version v3.6.2
# connecting to: mongodb://127.0.0.1:28000/social
# MongoDB server version: 3.6.2
# replset:PRIMARY>
# create a document in person collection
db.person.insert({"fname": "Shyam", "lname": "Arjarapu"})
# output of above command
# WriteResult({ "nInserted" : 1 })
db.getCollectionNames()
# The output of above command
# [ "person" ]
# drop the collection
db.person.drop()
# The output of above command
# true
db.getCollectionNames()
# The output of above command
# [ ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment