MongoDB operation commands, from official helper

Source: Internet
Author: User
Help show helpshow DBS show database namesshow collections show collections in current databaseshow users show users in current databaseshow profile show most recent system. profile entries with time> = 1 msuse <dB Name> set curent database to <dB Name> dB. adduser (username, password) dB. removeuser (username) dB. clonedatabase (fromhost) dB. copydatabase (fromdb, todb, fromhost) dB. createcollection (name, {size :..., capped :..., MAX :...}) DB. getname () dB. dropdatabase () // Runs the collstats] command on each collection in the database DB. printcollectionstats () dB. currentop () displays the current operation in the dbdb. killop () kills the current operation in the dbdb. getprofilinglevel () dB. setprofilinglevel (level) 0 = off 1 = slow 2 = alldb. getreplicationinfo () dB. printreplicationinfo () dB. printslavereplicationinfo () dB. repairdatabase () dB. version () Current version of The serverdb. shutdownserver ()

DB. Foo. Drop () Drop the collection
DB. Foo. dropindex (name)
DB. Foo. dropindexes ()
DB. Foo. getindexes ()
DB. Foo. ensureindex (keypattern, options)-options object has 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. Count ()
DB. Foo. Group ({key:..., initial:..., reduce:... [, Cond:...]})

DB. Foo. renamecollection (newname) renames the collection

DB. Foo. Stats ()
DB. Foo. datasize ()
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. Validate () (slow)

DB. Foo. insert (OBJ)
DB. Foo. Update (query, object [, upsert_bool])
DB. Foo. Save (OBJ)
DB. Foo. Remove (query)-remove objects matching Query
Remove ({}) will remove all

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.