Other knowledge about MongoDB

Source: Internet
Author: User

MongoDB supports full-text search and geo-spatial queries.

The current version of Mongdb3.4 starts to support the creation of views (view).

Capped Collections are fixed-size collection that support high-throughput operations for inserting and retrieving documents based on the insertion Order . The overridden collection works like a circular buffer: once the collection fills its allotted space, it will make room for the new document by overwriting the oldest document in the collection.

db.createcollection (name, options) method:

Because MongoDB implicitly creates a collection when the collection is first referenced in a command, this method is primarily used to create a new collection that uses specific options. For example, you use Db.createcollection () to create a Capped collections, or to create a new collection that uses document validation. Db.createcollection () is also used to pre-allocate space for normal collections.

  1. Db.createcollection (<Name>, {capped: <boolean>,
  2. Autoindexid: <boolean>
  3. Size: <number>
  4. Max: <number>
  5. Storageengine: <document>
  6. Validator: <document>
  7. Validationlevel: <string>
  8. Validationaction: <string>
  9. Indexoptiondefaults: <document>
  10. Viewon: <string>
  11. Pipeline: <pipeline>
  12. Collation: <document>})

capped : whether Capped Collections.

size: Optional. to be Capped CollectionsSpecifies the maximum size, in bytes. once the Limit collection reaches its maximum size,MongoDBolder documents will be deleted, freeing up space for new documents. sizeA field is required to cap a collection, while for other collections it is ignored.

Max : Optional. Capped Collectionsthe maximum number of documents allowed in the. Size If the CAP collection reaches the maximum number of documents before reaching size restriction, mongodb If you want to use the maximum limit, make sure that the size limit required to limit the collection is sufficient to contain the maximum number of documents.

Validator: Optional. allows the user to specify a validation rule or expression for the collection. new features in version 3.2.

read quarantine ( New in version 3.2.

Readconcern: {level:<"majority"|" Local "|" Linearizable "> }

Readconcern options are available for the following actions:

  • Find Command
  • Aggregate Command and the db.collection.aggregate () method
  • distinct Command
  • Count Command
  • Parallelcollectionscan Command
  • Geonear Command
  • Geosearch Command

used for replica sets and replica set shards. Readconcern the query options determine what data is returned from the query.

Readconcern level:

"Local" : default. the query returns the most recent data for the instance. data is not guaranteed to be written to most replica set members (that is, it can be rolled back).

"Majority": The query confirms that the latest data for the instance is written to most of the members in the replica set. You want to useMajoritylevel, you must use the--enablemajorityreadconcerncommand line Options startMongodinstance (if you use a configuration file, theReplication.enablemajorityreadconcernset totrue).

"Linearizable" ( Add in version3.4 ): The query returns data that reflects all successful writes.

Other knowledge about MongoDB

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.