Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

Randomizing MongoDB Document Fields on a Repeating Timer with Node.js

About a year ago I created a game with MongoDB and Unity and wrote about it in a previous tutorial. The idea was to demonstrate how features within the game could be synchronized to each player in near real-time. At the time, synchronization happened through a web dashboard where the player could select features to sync and they would then sync to the game client, wherever in the world it might be.

Recently, the game was adopted to be a demo at several conferences. The problem was that switching between the game and the web dashboard to demonstrate features being synchronized was a hassle. As a result, I decided to write a script that did this automatically on a timer.

In this quick tutorial, we’re going to see how to update documents within MongoDB on a timer, something that might be useful to you for demos and other potential use-cases.

Read More

Interact with a GraphQL API from a .NET Core Application

When it comes to C#, it’s not too difficult or time-consuming to create or consume RESTful APIs. In fact, I recently published a tutorial that demonstrated how to create a RESTful API with .NET Core using MongoDB as the NoSQL database.

RESTful APIs are great, but what happens when you want to work with GraphQL and query your APIs rather than just consume them?

In this tutorial, we’ll see how to use .NET Core to interact with a GraphQL API. To make things easier, we’ll generate our API with MongoDB App Services.

Read More

Developing a Web Application with Netlify Serverless Functions and MongoDB

As I mentioned in a previous tutorial, I’m a big fan of Netlify and the services they offer developers—my favorite of their services being their static website hosting and serverless functions. When combining the two, you can deploy a complex website or web application with a back end, without ever worrying about infrastructure or potentially complex API design.

So how does that work with a database like MongoDB?

If you’ve ever dabbled with serverless functions before, you might be aware that they are not always available for consumption. Many serverless functions exist for a defined amount of time and then are shut down until they are executed again. With this in mind, the connection to a database might not always be available like it would be in an application built with Express Framework, for example. You could establish a connection every time a function is called, but then you risk too many connections, which might overload your database.

So what do you do?

In this tutorial, we’re going to see how to build and deploy a simple web application using Netlify Functions and MongoDB Atlas. For this particular tutorial, we’ll be using the Node.js driver for MongoDB, but both Netlify and MongoDB support the use of other languages and drivers as well.

Read More

Intro to SQL for the New Grad Developer

Ever since studying and working with databases 6 months ago, I’ve become fascinated with SQL and its relatively simple syntax. As a guide to the reader, I’ve gathered the essential criteria that employers expect you to know when applying for a database-related job.

In this blog, I will cover what SQL is, its different flavors and syntactical differences centered around an example query, the importance of EXPLAIN and SQL query runtime, and finally some example problems specifically in MySQL.

Read More

Using LINQ to Query MongoDB in a .NET Core Application

If you’ve been keeping up with my series of tutorials around .NET Core and MongoDB, you’ll likely remember that we explored using the Find operator to query for documents as well as an aggregation pipeline. Neither of these previously explored subjects are too difficult, but depending on what you’re trying to accomplish, they could be a little messy. Not to mention, they aren’t necessarily “the .NET way” of doing business.

This is where LINQ comes into the mix of things!

With Language Integrated Queries (LINQ), we can use an established and well known C# syntax to work with our MongoDB documents and data.

In this tutorial, we’re going to look at a few LINQ queries, some as a replacement to simple queries using the MongoDB Query API and others as a replacement to more complicated aggregation pipelines.

Read More

Add a Comments Section to an Eleventy Website with MongoDB and Netlify

I’m a huge fan of static generated websites! From a personal level, I have The Polyglot Developer, Poké Trainer Nic, and The Tracy Developer Meetup, all three of which are static generated websites built with either Hugo or Eleventy. In addition to being static generated, all three are hosted on Netlify.

I didn’t start with a static generator though. I started on WordPress, so when I made the switch to static HTML, I got a lot of benefits, but I ended up with one big loss. The comments of my site, which were once stored in a database and loaded on-demand, didn’t have a home.

Fast forward to now, we have options!

In this tutorial, we’re going to look at maintaining a static generated website on Netlify with Eleventy, but the big thing here is that we’re going to see how to have comments for each of our blog pages.

Read More

Joining Collections in MongoDB with .NET Core and an Aggregation Pipeline

If you’ve been keeping up with my .NET Core series on MongoDB, you’ll remember that we explored creating a simple console application as well as building a RESTful API with basic CRUD support. In both examples, we used basic filters when interacting with MongoDB from our applications.

But what if we need to do something a bit more complex, like join data from two different MongoDB collections?

In this tutorial, we’re going to take a look at aggregation pipelines and some of the ways that you can work with them in a .NET Core application.

Read More

Search

Follow Us

Subscribe

Subscribe to the newsletter for monthly tips and tricks on subjects such as mobile, web, and game development.

Support This Site