MongoDB Atlas provides a set of API endpoints that can be used to access the database hosted on Atlas without the need for database drivers; great for minimal memory footprint, especially on serverless infrastructures such as AWS Lambda.
[Read More]Exactly Same Query Behaving Differently in Mongo Client and Mongoose
Understanding Mongoose's strict schema handling
You might notice that the same query behaves differently in a MongoDB client, like Compass or mongo shell, compared to when using Mongoose within a Node.js application. Below is one such scenario.
[Read More]MongoDB Single Update Query to Change the Field Name in All Matching Documents of the Collection
Including field name in nested object and array of objects.
Clean Up MongoDB Of Old Inactive Users And Their Data With Node Js Script
Reduce Expensive Database Space By Pruning Never-To-Be-Used-Again Data
Databases are not cheap, especially when your application is just taking off and you are low on budget. It is then that freeing up retrievable and precious space from the database is a good way to save some dollars for a while.
[Read More]
Build Queue For Processing Webhooks With Node Js And MongoDB
Manage The Flood Of Webhooks With A Database Queue
Many of the third party services we integrate in our applications use webhooks to communicate events to us. Responding to the incoming webhook with success response (status 200) is all that is required to acknowledge the receipt of the webhook. To process that webhook immediately upon receiving or entering it in a queue to be processed later is up to you.
[Read More]Intercept Node JS Console Log and Insert in MongoDB
Easily Manageable and Searchable Application Logs Stored in Database.
Your node js application is running on production, leaving hard-to-search ever-increasing log files in its wake. You want all your logs in a centralized, easily searchable place. For that, you have two options: 1 - Buy a subscription to some cloud log management service, such as papertrail.
[Read More]
With Update Method, Toggle Boolean Field in All Documents of a MongoDB Collection
Recently, I got a situation in which I had to update all user documents in mongoDB to toggle a boolean field. I was looking for single update query that could take care of it, but being a rare need, the problem had not many helpful solutions.
[Read More]
Export MongoDB Collection Data In CSV From Node Express Mongoose Application
Suppose a student collection in mongoDB have some data that we want to export in a CSV file from a Mongoose, Node, and Express app. For simplicity, let us assume only two fields in Mongoose schema: lastName and firstName. To export a CSV file, install moment, json2csv, and mongo-date-query (optional) npm packages:
[Read More]
When you purchase through links on techighness.com, I may earn an affiliate commission.