
- MongoDB Tutorial
- MongoDB - Home
- MongoDB - Overview
- MongoDB - Advantages
- MongoDB - Environment
- MongoDB - Data Modeling
- MongoDB - Create Database
- MongoDB - Drop Database
- MongoDB - Create Collection
- MongoDB - Drop Collection
- MongoDB - Data Types
- MongoDB - Insert Document
- MongoDB - Query Document
- MongoDB - Update Document
- MongoDB - Delete Document
- MongoDB - Projection
- MongoDB - Limiting Records
- MongoDB - Sorting Records
- MongoDB - Indexing
- MongoDB - Aggregation
- MongoDB - Replication
- MongoDB - Sharding
- MongoDB - Create Backup
- MongoDB - Deployment
- MongoDB - Java
- MongoDB - PHP
- Advanced MongoDB
- MongoDB - Relationships
- MongoDB - Database References
- MongoDB - Covered Queries
- MongoDB - Analyzing Queries
- MongoDB - Atomic Operations
- MongoDB - Advanced Indexing
- MongoDB - Indexing Limitations
- MongoDB - ObjectId
- MongoDB - Map Reduce
- MongoDB - Text Search
- MongoDB - Regular Expression
- Working with Rockmongo
- MongoDB - GridFS
- MongoDB - Capped Collections
- Auto-Increment Sequence
- MongoDB Useful Resources
- MongoDB - Questions and Answers
- MongoDB - Quick Guide
- MongoDB - Useful Resources
- MongoDB - Discussion
Is it possible to use MongoDB capped collection?
Yes, you can use capped. Capped collections are fixed-size collections that support high-throughput operations that insert and retrieve documents based on insertion order.
Let us create a collection with documents and set capped while creating a collection i.e. fixed-size collection −
> db.createCollection("demo539", { capped : true, size :100, max : 4 } ); { "ok" : 1 } > > > db.demo539.insertOne({"Name":"Chris"});{ "acknowledged" : true, "insertedId" : ObjectId("5e8c9094ef4dcbee04fbbc09") } > db.demo539.insertOne({"Name":"David"});{ "acknowledged" : true, "insertedId" : ObjectId("5e8c9098ef4dcbee04fbbc0a") } > db.demo539.insertOne({"Name":"Bob"});{ "acknowledged" : true, "insertedId" : ObjectId("5e8c909bef4dcbee04fbbc0b") } > db.demo539.insertOne({"Name":"Sam"});{ "acknowledged" : true, "insertedId" : ObjectId("5e8c909eef4dcbee04fbbc0c") } > db.demo539.insertOne({"Name":"Carol"});{ "acknowledged" : true, "insertedId" : ObjectId("5e8c90a4ef4dcbee04fbbc0d") }
Display all documents from a collection with the help of find() method −
> db.demo539.find();
This will produce the following output −
{ "_id" : ObjectId("5e8c9098ef4dcbee04fbbc0a"), "Name" : "David" } { "_id" : ObjectId("5e8c909bef4dcbee04fbbc0b"), "Name" : "Bob" } { "_id" : ObjectId("5e8c909eef4dcbee04fbbc0c"), "Name" : "Sam" } { "_id" : ObjectId("5e8c90a4ef4dcbee04fbbc0d"), "Name" : "Carol" }
- Related Articles
- Convert Collection to Capped in MongoDB
- Set max on MongoDB capped collection?
- What is the MongoDB Capped Collection maximum allowable size?
- MongoDB query for capped sub-collection in an array
- Is it possible to use variable for collection name using PyMongo?
- Invoke convertToCapped and convert an existing collection to capped in MongoDB
- How to update a single field in a capped collection in MongoDB?
- Is it possible to use MongoDB field value as pattern in $regex?
- Is it possible to use MongoDB field value as a pattern in $regex?
- Is it possible to cast in a MongoDB Query?
- Is it possible to use pyplot without DISPLAY?
- Is it possible to achieve a slice chain in MongoDB?
- Is it possible to write to MongoDB console in JavaScript execution?
- Is it possible to use Python modules in Octave?
- Is it possible to rename _id field after MongoDB group aggregation?

Advertisements