Skip to content

Instantly share code, notes, and snippets.

@NanoDano
Created June 3, 2020 20:42
Show Gist options
  • Save NanoDano/68debba98394efa995be40b7bcaae2e6 to your computer and use it in GitHub Desktop.
Save NanoDano/68debba98394efa995be40b7bcaae2e6 to your computer and use it in GitHub Desktop.
MongoDB example commands and queries from WebGenome project

Sample MongoDB commands

show dbs
use <db>  # also creates
show collections
db.getCollectionNames()
db.showCollections()
db.domains.getIndexes()
db.domains.stats()
db.domains.count()
db.domains.find()
db.domains.find({name:'www.devdungeon.com'})
db.domains.count({lastchecked:{$exists:true}, skipped: null})
db.domains.find({headers: {$elemMatch: {value: {$regex: 'Cookie'}}}}).pretty()
db.domains.find({headers: {$elemMatch: {key: {$regex: 'Drupal'}}}}).pretty()
db.products.insert( { item: "card", qty: 15 } )
db.<collection>.drop() # DELETE
db.dropDatabase()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment