![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Can we use the “.” symbol in MongoDB collection name?
Yes, we can use the “.” symbol in MongoDB collection name. Let us create a collection with documents −
> db.getCollection('demo28.example'); web.demo28.example > > > db.getCollection('demo28.example').insertOne({"Name":"Chris","Age":32}); { "acknowledged" : true, "insertedId" : ObjectId("5e15fbe48f2315c2efc48e6b") } > db.getCollection('demo28.example').insertOne({"Name":"Bob","Age":31}); { "acknowledged" : true, "insertedId" : ObjectId("5e15fbec8f2315c2efc48e6c") } > db.getCollection('demo28.example').insertOne({"Name":"David","Age":33}); { "acknowledged" : true, "insertedId" : ObjectId("5e15fbf38f2315c2efc48e6d") }
Display all documents from a collection with the help of find() method −
> db.getCollection('demo28.example').find().pretty();
This will produce the following output −
{ "_id" : ObjectId("5e15fbe48f2315c2efc48e6b"), "Name" : "Chris", "Age" : 32 } { "_id" : ObjectId("5e15fbec8f2315c2efc48e6c"), "Name" : "Bob", "Age" : 31 } { "_id" : ObjectId("5e15fbf38f2315c2efc48e6d"), "Name" : "David", "Age" : 33 }
Advertisements