Shell vs Drivers

A free video tutorial from Academind by Maximilian Schwarzmüller
Online Education
Rating: 4.6 out of 5Instructor rating
46 courses
2,823,961 students
Shell vs Drivers

Lecture description

When it comes to connecting to a MongoDB database, you got various options, most importantly: The local shell or drivers for different programming languages. Let me explain the differences.

Learn more from the full course

MongoDB - The Complete Developer's Guide 2024

Master MongoDB Development for Web & Mobile Apps. CRUD Operations, Indexes, Aggregation Framework - All about MongoDB!

17:29:23 of on-demand video • Updated January 2024

Learn what document databases are and how data is organized with MongoDB
Learn how to perform CRUD operations with MongoDB
Don't stop at the basics - learn all about writing complex MongoDB queries, in-depth and with practical examples!
Write efficient and well-performing queries to fetch data in the format you need it
Use all features MongoDB offers you to work with data efficiently
So for this course, we will primally work in this shell, to see all the commands and the different ways of using these commands because the shell is a great neutral ground for working with mongodb because I don't know if you're building a php, a node, a C++, a python or whatever application and I want to teach you something which you can apply to all use cases and that is the case with the shell but of course in the end, you will build an application with a programming language where this app should then issue these commands against the mongodb server. And for that, you can click on docs on the official page and then on the doc page, click on mongodb drivers because these drivers are packages you installed for the different programming languages your app might be written in, as you see you got drivers for all kinds of languages and these drivers are then your bridges between your programming language and the mongodb server and as it turns out, in these drivers, you use the same commands as I use in the shell, just adjusted to the syntax of the language you are working with of course. So for example, if we have a look at the nodejs driver and the python driver, let's see how we would work with those. On the nodejs driver documentation, if we click on latest documentation, we can quickly have a look at the quick start guide to see how our code would look like, if we use that, you see how to start your mongodb database and so on and what you will see there is that here, you also in the end just reach out to a database, then instead of typing the collection name, you have a collection method to get access but you would look into the official docs of course when using the driver, so these are tiny differences which you quickly find out there but then on the collection, you again run insertMany, we haven't seen that yet, we'll see it in the course, this exists in the shell in exactly the same way and you insert data in exactly the same way. So these, the core features are exactly equal, let's also have a look at python to prove that. Here I'm on the python driver page, now let me quickly dive into the tutorial, so that we see some code for that. So here, you see for python, you would install a package called py mongo which is the official driver for python, you then connect and so on and again, you in the end just get access to a database, then to a collection, here again by just using that collection name and then you simply insert one now using python syntax where you happen to write methods like this with an underscore and this snake case but then you insert one post which is just such an object, python map in the end. So you see, the syntax of the languages obviously differs because well, they are different languages but the general way of working with your data does not change at all, you work in exactly the same way as in the shell and actually, this is something we'll build later in the course. This is a complete node application using mongodb and here, you also see some code in action where I insert a new product and this is something we'll build in the course so that I can teach you how to move from the shell to the drivers but I hope this makes clear why we work with the shell, it's the neutral ground on which we all can agree so that you can take that knowledge on how to insert, how to configure your inserts, how to query data, how to filter data, how to sort data, so that you can use that knowledge with any driver you want and you are really flexible regarding what you built.