Skip to content

Instantly share code, notes, and snippets.

@rondinif
Last active February 6, 2016 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rondinif/335982ff41216629f91d to your computer and use it in GitHub Desktop.
Save rondinif/335982ff41216629f91d to your computer and use it in GitHub Desktop.
meteor's mongodb
welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-36-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
Last login: Sat Feb  6 04:52:13 2016 from 192.168.56.1
  bitnami@linux ~  
 05:03:01 $ ps aux | grep 'mongod'
bitnami  11224  1.6  1.0 634572 39284 pts/1    Sl+  05:01   0:01 /home/bitnami/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/mongodb/bin/mongod --bind_ip 127.0.0.1 --smallfiles --port 3001 --dbpath /home/bitnami/projects/coursera/meteor-development/dev/image_share/.meteor/local/db --oplogSize 8 --replSet meteor
bitnami  11311  0.0  0.0  10464   896 pts/2    S+   05:03   0:00 grep mongod
  bitnami@linux ~  
 05:03:03 $ ls -lrt /home/bitnami/projects/coursera/meteor-development/dev/image_share/.meteor/local/db
total 65552
-rw------- 1 bitnami bitnami 33554432 Jan 27 02:55 local.1
-rwxrwxr-x 1 bitnami bitnami        6 Feb  6 05:01 mongod.lock
drwxrwxr-x 2 bitnami bitnami     4096 Feb  6 05:01 journal
-rw------- 1 bitnami bitnami 16777216 Feb  6 05:01 local.ns
-rw------- 1 bitnami bitnami 16777216 Feb  6 05:01 local.0
-rw-rw-r-- 1 bitnami bitnami        4 Feb  6 05:01 METEOR-PORT
  bitnami@linux ~  
 05:04:08 $ cat /home/bitnami/projects/coursera/meteor-development/dev/image_share/.meteor/local/db/METEOR-PORT 
@rondinif
Copy link
Author

rondinif commented Feb 6, 2016

assumed to be in the same environment detected with the commands showed in the gist's README
we can start the mongo-shell:

cd ~/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/mongodb/bin
$ ./mongo -port 3001

and start to explore the meteor's mongoldb:

MongoDB shell version: 2.6.7
connecting to: 127.0.0.1:3001/test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
    http://docs.mongodb.org/
Questions? Try the support group
    http://groups.google.com/group/mongodb-user
meteor:PRIMARY> show dbs
admin  (empty)
local  0.063GB
meteor:PRIMARY> show collections
meteor:PRIMARY> use local 
switched to db local
meteor:PRIMARY> show collections
me
oplog.rs
startup_log
system.indexes
system.replset
meteor:PRIMARY> db.me.help()
DBCollection help
    db.me.find().help() - show DBCursor help
    db.me.count()
    db.me.copyTo(newColl) - duplicates collection by copying all documents to newColl; no indexes are copied.
    db.me.convertToCapped(maxBytes) - calls {convertToCapped:'me', size:maxBytes}} command
    db.me.dataSize()
    db.me.distinct( key ) - e.g. db.me.distinct( 'x' )
    db.me.drop() drop the collection
    db.me.dropIndex(index) - e.g. db.me.dropIndex( "indexName" ) or db.me.dropIndex( { "indexKey" : 1 } )
    db.me.dropIndexes()
    db.me.ensureIndex(keypattern[,options]) - options is an object with these possible fields: name, unique, dropDups
    db.me.reIndex()
    db.me.find([query],[fields]) - query is an optional query filter. fields is optional set of fields to return.
                                                  e.g. db.me.find( {x:77} , {name:1, x:1} )
    db.me.find(...).count()
    db.me.find(...).limit(n)
    db.me.find(...).skip(n)
    db.me.find(...).sort(...)
    db.me.findOne([query])
    db.me.findAndModify( { update : ... , remove : bool [, query: {}, sort: {}, 'new': false] } )
    db.me.getDB() get DB object associated with collection
    db.me.getPlanCache() get query plan cache associated with collection
    db.me.getIndexes()
    db.me.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )
    db.me.insert(obj)
    db.me.mapReduce( mapFunction , reduceFunction , <optional params> )
    db.me.aggregate( [pipeline], <optional params> ) - performs an aggregation on a collection; returns a cursor
    db.me.remove(query)
    db.me.renameCollection( newName , <dropTarget> ) renames the collection.
    db.me.runCommand( name , <options> ) runs a db command with the given name where the first param is the collection name
    db.me.save(obj)
    db.me.stats()
    db.me.storageSize() - includes free space allocated to this collection
    db.me.totalIndexSize() - size in bytes of all the indexes
    db.me.totalSize() - storage allocated for all data and indexes
    db.me.update(query, object[, upsert_bool, multi_bool]) - instead of two flags, you can pass an object with fields: upsert, multi
    db.me.validate( <full> ) - SLOW
    db.me.getShardVersion() - only for use with sharding
    db.me.getShardDistribution() - prints statistics about data distribution in the cluster
    db.me.getSplitKeysForChunks( <maxChunkSize> ) - calculates split points over all chunks and returns splitter function
    db.me.getWriteConcern() - returns the write concern used for any operations on this collection, inherited from server/db if set
    db.me.setWriteConcern( <write concern doc> ) - sets the write concern for writes to the collection
    db.me.unsetWriteConcern( <write concern doc> ) - unsets the write concern for writes to the collection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment