Mr. Deepak Verma
Web Developer
MongoDB mongosh Collections

Learn MONGO DB by M-Learnify

MONGO DB

MongoDB mongosh Collections


What is Collections in MongoDB:

MongoDB stores data records as documents (specifically BSON documents) which are gathered together in collections
A database stores one or more collections of documents.
You can manage databases and collections on the Atlas cluster from the Atlas UI, mongosh, or MongoDB Compass.

Create Collection using mongosh

You can create a collection using the createCollection() database method.

Example:
db.createCollection("students")



For example  school is a database name &  students  is a collection name.


Show or List Collections using mongosh
You can show or list collection using the show collections or  db.getCollectionNames() method.

Example:
show collections
or

db.getCollectionNames()


or



How to rename Collection name in mongosh
You can rename a collection using the renameCollection()  method.

Example:
db.students.renameCollection("student")

โ† Back to Courses
Course Lessons