Click here to Skip to main content
15,891,372 members
Everything / Database Development / MongoDB

MongoDB

MongoDB

Great Reads

by Marc Clifton
A deep dive into the $lookup aggregator with examples of one-to-one, one-to-many, many-to-many, and nested relational "queries"
by Vikas Sharma
In this article, we will focus on aggregation pipeline. I'll try to cover each major section of it using simple examples. We will be writing mongo shell commands to perform aggregation.
by Vyacheslav Voronenko
Three approaches to store tree like structures with NoSQL databases in MongoDB
by DiponRoy
Quick start example to run DB and clients in docker

Latest Articles

by Akram El Assas
Car Rental Platform with a mobile app
by Akram El Assas
Rental Property Management Platform with a Mobile App
by Akram El Assas
Microservices sample architecture using ASP.NET Core, Ocelot, MongoDB and JWT
by Akram El Assas
Open Source eCommerce Platform on Next.js

All Articles

Sort by Updated

MongoDB 

U 29 Apr 2024 by Akram El Assas
Car Rental Platform with a mobile app
U 29 Apr 2024 by Akram El Assas
Rental Property Management Platform with a Mobile App
23 Mar 2024 by Akram El Assas
Microservices sample architecture using ASP.NET Core, Ocelot, MongoDB and JWT
19 Dec 2023 by Aayushi Vaghasiya
I'm currently working on a project that involves a booking system. However, I've encountered an issue related to oversold bookings. Specifically, when two users attempt to book the same tickets simultaneously, the system sometimes ends up selling...
25 Oct 2023 by sahil ajmeri 2022
I have two dropdowns, machineType and machineProblem. I want to get machine problems using machineType selected in the Dropdown, I have an API for getting data from the database collection named machinetypeproblems. I want to show all the...
24 Oct 2023 by aledeol
I'm trying to do a generic persist method using reflecion and MongoDB. The normal code is: public bool InsertParent(ParentDTO parent) { var collection = db.GetCollection(ParentCollectionName); var...
22 Oct 2023 by Member 16121670
Hi, I know it's a bit late to answer this question, but you could use reflection to construct the generic method with something similar to this: //var typeO = objeto.GetType(); //here is the problem. The var typeO is not accepted. //var...
2 Oct 2023 by Bhanu Arora 2023
I want to store a high computational parameter to prevent its recomputation. But this parameter needs to be updated frequently to maintain consistency, should I use cache or a database or is there any other better solution for this?? I am using a...
29 Sep 2023 by OriginalGriff
All a Cache is is memory that is "closer to the processor" - often part of the same chip, and which is faster for the processor to access that having to go outside the CPU to main memory top get the value. And all frequent updates will do is...
14 Sep 2023 by Zenich TUW
I have the following issue: I'm building a chat using Node.js, Socket.IO, and MongoDB. Everything is working perfectly, except for the real-time aspect. For instance, when 'Sebas' sends a message to 'Gene', 'Sebas' can see that their message has...
16 Aug 2023 by Andre Oosthuizen
a Few changes is needed to make sure your message is sent and viewed - In chat.html - 1) Add a check to see if the user enters a message before sending it. 2) 'Listening' for the 'Enter' key press in the input field to send messages -
14 Aug 2023 by Sandeep Mewara
It's a well documented sample application for learning WebSocket (using socket.io & react/node.js). References: Video: Realtime Chat App with React, Node.js, Socket.io and MongoDB - YouTube[^] How to Create a Professional Chat API Solution...
10 Aug 2023 by Shubham Agrawal 2023
``` var express = require("express"); var cors = require("cors"); var mongoClient = require("mongodb").MongoClient; var connectionString = "mongodb://127.0.0.1:27017"; var app = express(); app.use(cors()); app.use(express.urlencoded({ ...
24 Jul 2023 by Akram El Assas
Open Source eCommerce Platform on Next.js
14 Jul 2023 by Akash Kr. Das
I have a MERN app, used Fetch API. I want to delete specific data upon clicking. Whenever i am clicking on delete its showing 'cannot delete.' and Status is 404: Not Found Here is my front end code please help me with this What I have tried: ...
14 Jul 2023 by Andre Oosthuizen
The problem lies within your 'removeElm' function when you try to laod 'userid - the path to 'demo/users is not found and thus no 'userid' is returned. Some steps to try and find the reason why the file is not found - 1) Make sure your localhost...
6 Jul 2023 by Rakesh subudhi 2023
I am building a Multi-Tenant web application using Java . I have around 10-15 different background jobs that need scheduling for each tenant.I faced multiple challenges like. 1.How to develop each tenant run on cron jobs and equally distributed?...
21 Jun 2023 by Member 16034634
I am making a blog website and want to implement a search alogithm which would be powered by ML. I took a codecademy course on ML but dont know how to combine MERN with ML. I also want to add a similar posts sections and also an algoritm to make...
29 May 2023 by Bárbara 2023
Hi everyone, Im tryingto to list the data coming from the mongo db in a file handlebars. But the problem is that when I load the screen, only the message "Category Listing" appears and the names of the categories do not appear as requested: ...
1 May 2023 by TooSmallToSee
I am trying write a program using nodejs-express and mongodb. I would send a post request and the filtered data from mongodb will be displayed on the html page. The program works but the connection is being made only at the beginning. Once...
28 Mar 2023 by Busenur Çetin
I solved the problem writing down how to do it in case someone will face with same error. 1)Move js folder in public folder 2)Write the code belove in signup.ejs: document.getElementById("adminSignup").onsubmit = (e) => { ...
28 Mar 2023 by Busenur Çetin
I keep getting this error on console.: "Refused to execute script from 'http://localhost:3000/js/main.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled." I tried every way I could find on the...
28 Mar 2023 by Dave Kreskowiak
You showed everything except the one line that loads the "main.js" script and that's the one that matters. Judging by the error message alone, you need to change that tag to read something like:
21 Mar 2023 by Office Systems
I'm having a spring boot project which looks for more than 50.0M documents in MongoDB when fetching from a single table everything works fine however the problem I'm experiencing is when joining two tables in order to check for customer status in...
21 Mar 2023 by Dave Kreskowiak
It takes forever because you're looking for a couple of strings, "Disabled" and "Opted Out", probably without any indexing on the field. This is probably the worst way to get the status in terms of performance. If you were looking for integer...
13 Mar 2023 by Office Systems
How can I compare month in spring mongo criteria with a hard corded value, month in criteria is in a spring format and the value is present in an integer format. This is what i have so far i just want to check for that month and group employee...
13 Mar 2023 by Dave Kreskowiak
Think about your query. What does ".is(2)" mean? Is it the month number? The day of the month? How about the yes? Maybe the hour, minutes, or seconds? How is your code telling the database that the 2 is a month? Hint: It's not.
27 Feb 2023 by Agnib Pyne 2022
Hi All, I am developing a whatsapp bot as per the client requirements, using python and mongodb. Currently, am using Twilio to test the app but I need to deploy the bot with my client's own number. That support is not available in Twilio, I...
20 Feb 2023 by Richard MacCutchan
See Learn about building, deploying, and managing your apps on Heroku.[^]
20 Feb 2023 by Agnib Pyne 2022
Hi All, I have developed a web application using .Net Core API, Angular and PostgreSQL. Also, a whatsapp chatbot has been developed using Python, Twilio and MongoDB. Now, I want to deploy these for client use and planning to host these in...
16 Jan 2023 by Andre Oosthuizen
You are adding a new client twice, at the start of your code and then again within another if else statement. I am not familiar with the code used ?-Java/MongoDb -? but the basics is the same How it works - 1. Search data table for client with...
16 Jan 2023 by Office Systems
I want to query all data which are present in my database by comparing with while loop data and if this data is available I want to update it and if not I want to insert it as a new record into the database. The problem is I'm only getting data...
24 Dec 2022 by Amogs
He guys, please I need some help with my NextJS/NodeJS project. I'm having the error: TypeError: Cannot read property '_id' of undefined at currentInstructor (C:\Users\Sammy\Desktop\eLearn\server\controllers\instructor.js:57:30 I can't...
24 Dec 2022 by Member 15874822
Just change User.findById(req.user._id) to User.findById(req.auth._id)
29 Nov 2022 by Madhurima Dutta
So i need to connect to mongo db with my c# code where i pass the guid as an argument and fetch the job data which matches that guid from the mongo db document. PS : I am both new to Mongo DB and C#. So basically need to know how get information...
9 Nov 2022 by Vamsi Deepak
I am using $graphlookup with mongoose , it is working fine in mongoplay ground but in nodejs it is not giving tree structure data. Instead it is giving TreeResult as empty array Please find the below details: below is the my method in nodejs...
23 Oct 2022 by priyamtheone
Using Node, Express and Mongoose, I'm trying to insert data into MongoDB through a POST method. The fields I'm trying to insert has a phone field on which I'm trying to assign a validation that will check if it has minimum ten digits. Otherwise,...
23 Oct 2022 by Richard MacCutchan
You have defined phone as a Number with a minimum value of 10. If you want to validate the number of digits then it needs to be a String. See Mongoose v6.6.7: Validation[^].
20 Sep 2022 by Malika Taouai
I have two collections "transactions and books", I applied the $project operator to find the difference between the two dates and I got the result with minutes, so then I used the $lookup operator to join the two collections and to get as a...
20 Sep 2022 by khraLiezx
Hello, I have a WinForm application. With this application, I insert the incoming orders detail into the MongoDB database. Some of my data types are Objects and inside the Objects again I have Objects Example of my Data in Database: "Products":...
12 Sep 2022 by Jasmine L
error: OperationFailure: Unknown type name alias: moviename, full error: {'ok': 0.0, 'errmsg': 'Unknown type name alias: moviename', 'code': 2, 'codeName': 'BadValue'} What I have tried: type = db.col.find({'type': {'$type':'moviename'} })...
4 Sep 2022 by jon773599
I got index file code in output in Chrome first check this link My output in chrome click this link check In above link you can check my index,js file What I have tried: My package.json file { "name": "fact_new_backend", "version":...
2 Sep 2022 by khraLiezx
In this way, the data comes from the database in a mixed way with different prices. 1. Product = Laptop Price=100 Quantity=105 2. Product = Monitor Price=110 Quantity=130 3. Product = Tel Price=200 Quantity=250 4. Product= TV ...
2 Sep 2022 by CHill60
Richard's idea is a good one and simple to implement. However it does not cater for growing data. I suggest that you extract the data as individual rows (per product per price) and then pivot that datatable to produce another Here are a couple...
15 Aug 2022 by Prathmesh Upadhyay
-2 I am working with mongodb and python flask. Every time I run flask I receive this error on the local host and the terminal query = db.Data.find(upsert=True) AttributeError: 'NoneType' object has no attribute 'Data' What I have tried: ...
15 Aug 2022 by Richard MacCutchan
You need a method to get the database reference, the db variable does not exist in the functions you are using. See Welcome to Flask — Flask Documentation (2.1.x)[^] for details of how to do it correctly.
4 Aug 2022 by canvas_newbi
I have a collection of Groups and a collection of People (each Group or People have a unique ID). Group can hold X amount of People. I'm using the microservice methodology so my collections can't be linked together. I'm need to populate the array...
29 Jul 2022 by Ryan Impossible
Did a Udemy course on MERN stack. Now planning to take up a fresher position or internship to start my career. What projects would look good on my resume? What I have tried: I have made some to-do apps but I think it won't set me apart.
21 Jul 2022 by Yoni Kirby
Hello, I have put code to create a mongoose document on mongo atlas inside a promise, which gets added 5214 times ("in promise" counter). However, the code after the call ("in create response:" counter) to create the mongoose object only gets...
6 Jul 2022 by DiponRoy
Quick start example to run DB and clients in docker
28 Jun 2022 by ale fan
I got this problem throw new MongooseError('The `uri` parameter to `openUri()` must be a ' + I am uploading my full be please tell me what i can do What I have tried: **index.js** const Koa = require("koa"); const KoaRouter =...
6 Jun 2022 by jimmy emanon
Hello :). I am stuck in a node.js Blog project. I am using the templating engine edge for an online course that I am taking. The instructor has chosen to use edge as the templating engine. I am not sure if edge is the problem? When I use: ...
2 Jun 2022 by Divija Thommandru
I have make a union of two collections without any conditions, and need to project all fields in both tables in one query. But with my query I am able to see the output of customer_id, name and concatination. The collection data which I am trying...
28 May 2022 by Member 15653979
I have all the data I need in the mongoDB Database, I just dont know how I can send parts of the data in an Discord embed. for example the data: new birthdaySchema({ User: username.username, Birthday: birthdayString, Month: showMonth, ...
19 May 2022 by André Marcos (Advisor), GracianoSouza
React Native, Node.js and PostreSQL, a PERN stack to develop an app to support the lost pets searching process
18 May 2022 by SriNivas IT
How to DB First approch with Mongo DB can be performed in .Net Core 5.0 / 6.0 Web API ?? What I have tried: How to DB First approch with Mongo DB can be performed in .Net Core 5.0 / 6.0 Web API ??
18 May 2022 by Richard MacCutchan
DB First approch with Mongo DB - Google Search[^]
25 Apr 2022 by stackprogramer
For my express.js project, I use the migrate package to manage the Models of my Mongo database. I defined database object in db.js file.Then I used it in migrate file. //db.js file const mongoClient = require('mongodb').MongoClient; const...
18 Apr 2022 by priyamtheone
I have MongoDB version 5.0.7 installed in the default location in my PC running on Windows 10 Pro. I have a database named mydb which contains a collection called products. I want to copy the mydb database into a new database called newdb. For...
18 Apr 2022 by priyamtheone
I found the reason. The problem lies in using single quotes while passing the values of --nsFrom and --nsTo arguments. While doing so, in some environments, mongo keeps on restoring the dump to the existing database instead of the new one, thus...
16 Apr 2022 by Saurabh Suman 2022
///backend code first ///User Schema const UserSchema = new mongoose.Schema( { username: { type: String, required: true, unique: true }, name: { type: String }, email: { type: String, required: true }, mobileNo: { type:...
16 Apr 2022 by Mr Dev 2022
const [input, setInput] = useState([]); change this code like this. const [input, setInput] = useState({});
13 Mar 2022 by Arslan Anjum 2021
I have searched a lot but couldn't solve this problem. This is the Schema const ToDosSchema = mongoose.Schema({ userId: { type: String, required: true }, ToDo: [{ Task: { type: String, ...
2 Mar 2022 by Oliver Smith 2022
Save time comparing JSON docs and build collaboration features into your applications
23 Feb 2022 by amsga
Hi All, I was wondering if there is any mechanism similar to Entity Framework Migration to populate a MongoDB collection? I am trying to prepopulate a MongoDB collection with some defaults through code level rather than manually exporting and...
28 Jan 2022 by NOOBLAKHINA
This is my code for the parent component:- {isAuthenticated && } {/* }/> */}...
15 Jan 2022 by Member 15489508
i Have masterdatafile its about 4GiG And more than 45 million records. How can i load this data in MongoDB? What I have tried: I have tried nothing so far.i just downloaded MongoDb
15 Jan 2022 by OriginalGriff
Perhaps this will help: Import Data into MongoDB[^]
14 Jan 2022 by Cyber Noob
This is the error I obtain while running the below code. Traceback (most recent call last): File "E:\Anaconda Projects\Mongo Projects\SDR Tool\csvtojson.py", line 16, in jsonString = json.dumps(jsonArray, indent=1,...
2 Jan 2022 by Norah Alothman
post schema: const BlogSchema = new mongoose.Schema( { title: { type: String }, content: { type: String }, author: { type:...
5 Dec 2021 by Emilio Brioso
The code is written to upload a document to mongoDB with a photo attached. The code works and the document is actually pushed to my mongoDB database. However, I just want to return something once the function ends so that I can generate a proper...
5 Dec 2021 by Chris Copeland
In addition to Richard's comment about correctly using async/await in your JS, you're also using it in places where it isn't fully supported. For example, the JS array functions forEach() and map() don't return Promise objects. let imgArray =...
5 Dec 2021 by Richard Deeming
Why are you mixing async/await with the old-style .then/.catch calls? Just use async code: try { await newProduct.save(); console.log(true); return true; } catch (error) { if (error.name === 'MongoError' && error.code === 11000)...
5 Dec 2021 by Chinedum Ike
Okay so I just finished a 10 hour nodejs and mongodb course but whenever I look at all the cool apps you can build with node I still feel like I dont know anything since all I learnt was CRUD operations. So my question is does anyone have like a...
5 Dec 2021 by Gerry Schmitz
How to build a real time chat application in Node.js using Express, Mongoose and Socket.io[^] How to Code a Video Streaming Server using NodeJS - DEV Community[^] ...
24 Nov 2021 by Arctype SQL
There are three major types of database models in use today. Learn about their differences and what applications they are good for.
22 Nov 2021 by mattdimicelli
I have a model ItemModel and another model, ItemInstances. Hopefully those names are self-explanatory. I want to create a virtual in my Mongoose ItemSchema that will return the number of ItemInstances that are associated with that Item and that...
9 Nov 2021 by Daniele Fontani
That is the question. A comparison between these two technologies and some tips to choose the best that suits your needs.
24 Oct 2021 by Prathmesh Upadhyay
I am using android studios and MongoDB atlas as database. But I cannot take output at the "usernameval" string. Please check my code and help me. The output for " Log.v("msg","name"+usernameval);" in page 1 is V/msg: name thus value of...
24 Oct 2021 by Prathmesh Upadhyay
just put usernameval=usernamegiven.getText().toString(); in the onclock listner @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ...
25 Sep 2021 by Member 15371426
I am using passport to implement a login function on my application. However, every time I try to authenticate the user, I cannot get passed the authentication and am redirected to the failure URL. I have confirmed that there is a user in the...
21 Sep 2021 by YustasDev13
I have a driverStores collection where each Store has a Product collection { "_id": ObjectId("61444bad0e945f654c1c4918"), "storeName": "One", "listProducts": [ { "_id": ObjectId("61444bc70e945f654c1c491f"), "productName": "Water",...
12 Sep 2021 by YustasDev13
I have a simple (working) query from unwind to MongoDB, how can I write this query using Jongo? db.stores.aggregate([ { $unwind: "$listProducts" }, { $match : { "listProducts.productPrice" : { $ne : 0 } } }, { $group : { _id : { storeName :...
12 Sep 2021 by Richard MacCutchan
See Jongo {mongo-java-driver: 'with ease'}[^]
31 Jul 2021 by Heman Kadariya 2021
I have an api to connect top the nodejs and on calling that api i want to update votes array to true such that everytime the api is called, new boolean should be added. How can i do this? This is how my database is structured and i want to...
8 Jul 2021 by aneesh aneesh s
I am doing paging of notification list using the below code, As you can see the model has so many fields which I don't want. I just want listed id, name only to show the outer details which does not need the content or anything else. How can I...
6 Jun 2021 by ibilalkayy
func Uploadfile(filename, filepath string) { data, err := ioutil.ReadFile(filename) if err != nil { log.Fatal(err) os.Exit(0) } bucket, err := gridfs.NewBucket( CNX.Database("VWS"), ) if err != nil...
6 Jun 2021 by Richard MacCutchan
Quote: Although the path is correct. The error message is clearly telling you that the path is not correct. I suspect there should be a forward slash at the beginning: "/home/bilal/Videos".
22 May 2021 by Ammu Varughese
I want to display the updating count of vehicles on a particular road in my google maps w.r.t to a marker I have placed.I am using the MongoDB database from which I retrieve the count value and want to display this real time count in my map. Is...
17 May 2021 by Aman Parmar
a)I want to connect to MongoDB b)Surround Mondodb with try-catch block c)catch exceptions. I have to use git to get the latest branch. I have assumed that the below command will run before MongoDB connection: source setenv.sh source...
22 Mar 2021 by Member 15090354
I have created mongo db and trying to call collection in asp.net core web api i am getting the below exception A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors =...
22 Mar 2021 by thatraja
These might fix the issue How to fix MongoDB connection timeout?[^] c# - A timeout occured after 30000ms selecting a server using CompositeServerSelector - Stack Overflow[^]
18 Mar 2021 by VijayRana
A tutorial for MongoDB Tutorial
9 Mar 2021 by Vedant Nandwana
I am trying to to map a list with json data, all is going well but when I am trying to map a button with value, it is giving undefined . List of data is like this - var data = { name: 'routes', size: '0MB', path:...
1 Mar 2021 by Deep Dipe
I am trying to create a program that allows users to create lists and save data inside lists. I have created two pages first page has the data and second page where you create a list. Let me tell you the problem, as if I create three lists and I...
1 Mar 2021 by W Balboos, GHB
You have to first consider that security makes it impossible to for a web page on your client to access another webpage - UNLESS - the targeted page is a child page of the one that sending the data. If that's the case, you can use the DOM to...
9 Feb 2021 by SaraK.M
I'm uploading a video and an Image(to use as the thumbnail for video) from an ejs form, using multer, they successfully upload and I have access to them however, I can't update/edit them properly, since I have to reupload both files every time...
6 Feb 2021 by RickZeeland
This article might get you started: Simple QT Application for data entry to MongoDB using Python and mongoengine[^] The source code can be found here: GitHub - frodrig3ND/QT_Mongo_DB: Simple QT Application to interact with MongoDB[^]