Tag: mongodb
How to Install MongoDB on Ubuntu: A Step-by-Step Guide for Beginners
So you're ready to dabble with MongoDB on Linux and you've chosen Ubuntu as the variant you want to work with. Fantastic choice because you're in for a fairly easy experience that will get you up and running with MongoDB in no time!
In this tutorial, we'll explore installing MongoDB through the Ubuntu Package Manager and do some minor quality of life improvements that will better secure your installation from the rest of the world. While we'll be exploring the native installation experience, if you'd prefer to use Docker on Ubuntu for working with MongoDB, check out my previous tutorial, Running MongoDB in Docker - A Complete Guide with Examples.
Read MoreRunning MongoDB in Docker - A Complete Guide with Examples
So you're looking to self-host MongoDB or start dabbling with it in a local setting? There are a few options to get started if you don't want to jump directly into MongoDB Atlas, one of those options being containers with Docker. Making use of Docker is a solid choice when managing your MongoDB instance because it doesn't take more than a minute to do and it is easy to maintain or move between host computers.
In this article, we're going to see a few approaches toward deploying MongoDB with Docker and explore a few tips and tricks along the way.
Read MoreHow to Design Nested Documents for a Blogging App
So you want to build your own content management system (CMS), also sometimes known as a blog? This is a classic example when learning how to use a database, whether it be a relational database management system (RDBMS) or a NoSQL database, because it explores a potentially large amount of data as well as relationships in that data. The example of a blogging app also translates well for other data modeling needs.
In this article, we're going to explore some do's and don'ts when it comes to designing your NoSQL documents in MongoDB. However, we won't actually be developing a blogging app, only looking at things from a data perspective.
Read MoreMongoDB and GraphQL: A Perfect Match
GraphQL is a powerful and efficient way to build APIs. The client queries the API, similarly to how they would a database, and that API returns only the data that they've requested, often reducing the response payload and improving response times. Low response times are critical in the modern world.
When the GraphQL API is paired with MongoDB, you're not only getting those fast response times, but you're also getting a data format that is consistent from start to finish.
Imagine this: Your client is executing a GraphQL query and that query looks similar to JSON. When the data reaches your application—which, let's say, is TypeScript in this example—you're now working with a data format that is similar to JSON in your application. Taking it a step further, when working with MongoDB, the data you send to and from MongoDB will also be similar to JSON. So what you're getting is that consistent data experience on top of performance. No need to worry too much about manipulating and formatting your data, and instead you get to focus on the user experience of your application, not the database and tooling.
In this tutorial, we're going to see just how easy it is to use MongoDB in your GraphQL API, this time built with TypeScript.
Read MoreBuilding a REST API With Express Framework and MongoDB
Almost every modern web application will need a REST API for the frontend to communicate with, and in almost every scenario, that frontend is going to expect to work with JSON data. As a result, the best development experience will come from a stack that will allow you to use JSON throughout, with no transformations that lead to overly complex code.
Take MongoDB, Express Framework, and Node.js as an example.
Node.js and Express Framework handle your application logic, receiving requests from clients, and sending responses back to them. MongoDB is the database that sits between those requests and responses. In this example, the client can send JSON to the application and the application can send the JSON to the database. The database will respond with JSON and that JSON will be sent back to the client. This works well because MongoDB is a document database that works with BSON, a JSON-like data format.
In this tutorial, we'll see how to create an elegant REST API using MongoDB and Express Framework.
Read MoreUsing Dot Notation to Query Nested Fields in MongoDB
If you're just starting to dabble with MongoDB, you've probably come to a point where your documents are looking a little complex. These documents might have gone from flat, relational-looking pieces of data to something with nested objects, nested arrays, and maybe even four or five more levels of nesting. So how do you query this data when it is a few layers deep?
In this short tutorial, we're going to look at dot notation within MongoDB and see how we can very quickly and easily filter our documents based on data that contains certain values in the nested fields.
Read MoreBuild a Movie Watchlist with Node.js, TypeScript, and MongoDB
Almost every modern web application will need a REST API for a client to talk to, and in almost every scenario, that client is going to expect JSON. The best developer experience is a stack where you can stay in JSON-shaped data end to end, without awkward transformations in the middle.
Take MongoDB, Express Framework, and Node.js as an example.
Express receives HTTP requests and sends responses. MongoDB sits in the middle and stores documents. The client can send JSON to your routes, your routes can send documents to MongoDB, and MongoDB can hand BSON back that maps naturally to what you serialize in the response. That works well because MongoDB is a document database. When you also want text search over fields like title and plot, MongoDB Search gives you a $search stage in an aggregation pipeline on the same cluster, so you are not bolting on a separate search system just to power a search box.
In this tutorial, we'll see how to build a small movie watchlist API using TypeScript and MongoDB. We'll explore a few different schema design opportunities and make use of MongoDB Search for full-text search.
Read More