Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering MongoDB 4.x

You're reading from   Mastering MongoDB 4.x Expert techniques to run high-volume and fault-tolerant database solutions using MongoDB 4.x

Arrow left icon
Product type Paperback
Published in Mar 2019
Publisher Packt
ISBN-13 9781789617870
Length 394 pages
Edition 2nd Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Alex Giamas Alex Giamas
Author Profile Icon Alex Giamas
Alex Giamas
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Section 1: Basic MongoDB – Design Goals and Architecture FREE CHAPTER
2. MongoDB – A Database for Modern Web 3. Schema Design and Data Modeling 4. Section 2: Querying Effectively
5. MongoDB CRUD Operations 6. Advanced Querying 7. Multi-Document ACID Transactions 8. Aggregation 9. Indexing 10. Section 3: Administration and Data Management
11. Monitoring, Backup, and Security 12. Storage Engines 13. MongoDB Tooling 14. Harnessing Big Data with MongoDB 15. Section 4: Scaling and High Availability
16. Replication 17. Sharding 18. Fault Tolerance and High Availability 19. Other Books You May Enjoy

CRUD using the shell

The mongo shell is equivalent to the administration console used by relational databases. Connecting to the mongo shell is as easy as typing the following code:

$ mongo

Type this on the command line for standalone servers or replica sets. Inside the shell, you can view available databases simply by typing the following code:

$ db

Then, you can connect to a database by typing the following code:

> use <database_name>

The mongo shell can be used to query and update data into our databases. Inserting this document in the books collection can be done as follows:

> db.books.insert({title: 'mastering mongoDB', isbn: '101'})
WriteResult({ "nInserted" : 1 })

We can then find documents from a collection named books by typing the following:

> db.books.find()
{ "_id" : ObjectId("592033f6141daf984112d07c"...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime