Sunday, December 22, 2013

Try mongodb

http://try.mongodb.org/
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/
>
DBCollection help
db.foo.count()
db.foo.dataSize()
db.foo.distinct( key ) - eg. db.foo.distinct( 'x' )
db.foo.drop() drop the collection
db.foo.dropIndex(name)
db.foo.dropIndexes()
db.foo.ensureIndex(keypattern,options) - options should be an object with these possible fields: name, unique, dropDups
db.foo.find( [query] , [fields]) - first parameter is an optional query filter. second parameter is optional set of fields to return.
e.g. db.foo.find( { x : 77 } , { name : 1 , x : 1 } )
db.foo.find(...).count()
db.foo.find(...).limit(n)
db.foo.find(...).skip(n)
db.foo.find(...).sort(...)
db.foo.findOne([query])
db.foo.getDB() get DB object associated with collection
db.foo.getIndexes()
db.foo.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )
db.foo.mapReduce( mapFunction , reduceFunction , )
db.foo.remove(query)
db.foo.renameCollection( newName ) renames the collection
db.foo.save(obj)
db.foo.stats()
db.foo.storageSize() - includes free space allocated to this collection
db.foo.totalIndexSize() - size in bytes of all the indexes
db.foo.totalSize() - storage allocated for all data and indexes
db.foo.update(query, object[, upsert_bool])
"
DBCollection help
show collections              show collections in current database
db.help()                     help on DB methods
db.foo.help()                 help on collection methods
db.foo.find()                 list objects in collection foo
db.foo.save({a: 1})           save a document to collection foo
db.foo.update({a: 1}, {a: 2}) update document where a is 1
db.foo.find({a: 1})           list objects in foo where a == 1
it                            result of the last line evaluated; use to further iterate

No comments:

Post a Comment