MongoDB

Repair and restart mongo

http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian-or-ubuntu-linux/

http://www.mongodb.org/display/DOCS/Starting+and+Stopping+Mongo

  sudo chown -R mongodb:mongodb /var/lib/mongodb/
sudo -u mongodb mongod --dbpath=/var/lib/mongodb/ --repair
sudo service mongodb start

Finding indexes

> db.system.indexes.find()

Repair Mongo after bad termination

Remove mongod.lock

mongod --dbpath ~/data/db/ --repair

http://www.mongodb.org/display/DOCS/Durability+and+Repair

Mongo dump and restore

mongodump --db lux
tar -xvf dump-20120401.tar.gz
mongorestore dump

Drop database

use foo; db.dropDatabase();

Drop collection

http://www.mongodb.org/display/DOCS/Overview+-+The+MongoDB+Interactive+Shell

db.foo.drop()

drop the entire foo collection

GUIs for examining

http://www.mongodb.org/display/DOCS/Admin+UIs

Retrieve a subset of fields

http://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields

OpenID, Django, Mongo

https://github.com/arielbackenroth/openid-mongodb - storage for openid transactions

/data/db ownership settings

Change ownership of /data/db and all files inside: http://stackoverflow.com/questions/7948789/mongodb-mongod-complains-that-there-is-no-data-db-folder

Storing files with MongoDB

http://stevechallis.com/2010/oct/18/so-gridfs-mongoengine--django-walk-into-a-bar-/

Mongoengine

Selecting by a field in EmbeddedDocument

receipt = Receipt.objects(__raw__={'transaction.id': int(id)})
if receipt:
    receipt = receipt[0]
Last edited by Artem Dudarev, 2013-10-13 02:01:37. Edit