All Questions
50,450 questions
-2
votes
0
answers
16
views
How to Generate Reports from MongoDB Community Edition and Integrate Them into a React UI?
I am using MongoDB Community Edition as my database and need to generate reports based on the data stored in my collections. The reports should be query-driven and provide insights such as aggregated ...
0
votes
1
answer
32
views
Error handling in NodeJS service classes and controllers
I am very new to both JavaScript and NodeJS and am struggling to grapple some of the concepts surrounding async, promises, and others, and especially how to structure the code properly. I am trying to ...
-1
votes
0
answers
22
views
MongoDb- Node.js server mistakes [duplicate]
DB Error: MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted....
1
vote
1
answer
38
views
is it possible to check whether the user-given foreignFieldId (req.body.foreignFieldId ) exists or not before calling db.create(req.body) in MongoDB
Product Schema:
const productSchema = new mongoose.Schema({
name: { type: String, required: true },
price: { type: Number, required: true },
addedBy: { type: mongoose.Types.ObjectId, ref: '...
-1
votes
0
answers
24
views
connect with mongodb atlas and choode render for hosting i got below error when url change to atlas,when url is localhost 27017 there is no error
const timeoutError = new error_1.MongoServerSelectionError(`Server selection timed out after ${timeout?.duration} ms`, this.description);
^
MongoServerSelectionError: 38A70000:...
-2
votes
0
answers
32
views
Automatic response header writing in nodeJS [closed]
I'm having a problem with a controller (create), each db call made using mongoose (look at the service) will automatically write to response headers with no manual control over it, that's leading to ...
-2
votes
0
answers
15
views
"message": "E11000 duplicate key error collection: BusBooking.bookings index: adminId_1 dup key: { adminId: null }", [closed]
first created a booking collection using adminId and busId
then one document added to collection
now I change the model to userID and busId
it show this error
I try to delete the collection and ...
0
votes
1
answer
79
views
a confusion about schema design for storing store's profits and how to retrieve them in mongoose [closed]
For displaying the (daily-weekly-monthly-annual) total profits for the store's dashboard.
I want to store the data in an array for each store to not have multiple docs for the same store but different ...
0
votes
1
answer
49
views
How can I properly handle database connections in a Node.js application?
I'm building a Node.js application using Express.js and MongoDB (Mongoose). I want to ensure that my database connections are handled efficiently to avoid memory leaks and connection issues.
Currently,...
-2
votes
1
answer
49
views
Is Mongoose really an ORM, or is it something else? [duplicate]
I keep hearing people say that Mongoose is an ORM for MongoDB, but I thought ORMs are for relational databases like MySQL or PostgreSQL. Since MongoDB doesn’t use tables and rows but instead works ...
0
votes
1
answer
52
views
How to effectively handle multiple message in Kafka?
I've test performance of my consumer and the result is not good.
The consumer job is mapping incoming message from Kafka and storing it into DB (MongoDB).
I use NodeJS and ExpressJS for the server.
...
-1
votes
0
answers
24
views
Error when deploying full stack app on render
I'm attempting to deploy my full stack chat app thru render but I keep getting a build error of: frontend/node_modules/rollup/dist/es/shared/parseAst.js. My build settings are npm run build and for ...
0
votes
0
answers
47
views
Next.js Prisma Base Service: UserDelegate Error with Related Schemas
In my Next.js project, I created a BaseService using Prisma and extended it for sub-services. Everything works fine for normal usage, but when I try to use this approach with schemas that have ...
0
votes
2
answers
67
views
POST document hook or middleware in mongoose isn't working
I'm using mongoose v8.7.3, here is part of my code which is not working as expected.
const updateOne = (Model) => catchAsync(async (req, res, next) => {
const doc = await Model....
1
vote
0
answers
81
views
Setting cookie's domain causes TypeError: option domain is invalid
Follow-up from Express session loses passport user ID on a Safari cookie every week . In Express and NodeJS, I want to set a cookie's domain so user agents see it as a first-party cookie. If I set it ...
-1
votes
0
answers
38
views
mongoDb cant find user in adminDB
I am just starting to learn Nodejs and MongoDB, unfortunately I have a problem right at the beginning.
after I have created a MongoDB with user and password via Docker (a Docker desktop is running in ...
1
vote
0
answers
47
views
Unable to connect AWS lambda to Mongodb through VPC [closed]
AWS Lambda MongoDB Atlas Connection Timeout Issue (VPC Peering)
I have an AWS Lambda function that connects to a MongoDB Atlas cluster. To enable this connection, I have:
Configured a VPC and peered ...
1
vote
1
answer
40
views
Next.js + Mongo/Mongoose query taking 3+ minutes in local dev: “DB Query time: 168,000 ms”
When a user logs in on src/app/page.tsx, I redirect them to /student/dashboard, which calls my /api/tasks endpoint (passing ?userId=...&page=1&limit=20) to load the user’s tasks. However, my ...
0
votes
1
answer
44
views
Node.js script hangs after saving documents to MongoDB with Mongoose, despite successful document saves
I have a Node.js script that uses Puppeteer to scrape job vacancy IDs from a website and Mongoose to save those IDs to a MongoDB database. Each vacancy is saved correctly, but the script hangs after ...
0
votes
1
answer
70
views
Find by array of Ids not working with Mongoose aggregate method
I would like to use the aggregate in mongoose to get documents that match the ids in the array.
The array contains mongoose object ids.
It is returning an empty array. Here is my code:
let ...
0
votes
1
answer
43
views
mongodb push update based on ne and arrayfilters not working
I'm trying to create a patch API for a database of products in a MERN application that keeps track of expiry dates.
The idea is when a product's UPC is given, as well as the date in which it expires, ...
0
votes
0
answers
49
views
mongodb boolean value is not updating
I am trying to update "has_signed" value to true but its not working note that my table model structure is like this:
export interface AdminOffersInterface {
//other fields
seller: [{
...
0
votes
1
answer
40
views
Mongoose - How to read findOneAndUpdate result when includeResultMetadata flag is set?
I am using mongoose findOneAndUpdate (reference) query function with includeResultMetadata and lean flags set. It responds with object of type ModifyResult (reference) which looks like:
{ ...
0
votes
0
answers
20
views
Passport.js session not persisting after login in Express & MongoDB
I'm implementing authentication in my Node.js (Express) application using Passport.js and MongoDB (Mongoose). The issue is that after logging in, the session stores the user in MongoDB, but on ...
1
vote
1
answer
54
views
Express session loses passport user ID on a Safari cookie every week
I've been studying this bug for a while. I have a NodeJS application with cookies when logging in, and the cookies are supposed to last one year. I check the application every day on Google Chrome, ...
0
votes
0
answers
15
views
interface for model and general in ts
I am stuck in a situation please help.
I created a interface for User Model in mongoose and ts. the model has profile pic field which consists of a reference to document model. so my user schema model ...
-1
votes
0
answers
34
views
Postman 400 Bad Request Error: This request could not be fulfilled due to bad syntax
I am new to working with Postman, and I am working on learning the MERN tech stack, starting with this tutorial playlist (MERN Authentication System With Email Verification). I am on this video (...
0
votes
1
answer
28
views
How to add a required value with a middleware?
I want to make the generation of the codigoSS before the validation but when i try the end point i recibe the message: "Solicitud validation failed: codigoSS: Path codigoSS is required.".
...
2
votes
1
answer
51
views
How do I clear all indexes in a newly instantiated reused Schema?
I'm developing a Mongoose plugin that archives documents on every update by cloning the original schema. However, I'm facing an issue with unique fields: when a field is marked as unique, Mongoose ...
0
votes
1
answer
73
views
Which data should I fetch from database to leave classroom?
I'm building a MERN project i.e. a Teacher's forum application where teachers can create their own classroom & give access to particular students through OTP service. But while I'm building a ...
0
votes
1
answer
41
views
Mongoose replica set with docker
I spend whole day trying to figure out how can I convert my standalone mongod to Replica Set I and have failed. This is how I'm doing it without replication.
docker-compose.yaml
volumes:
mongo....
0
votes
2
answers
102
views
Can't connect to my mongdb database using mongoose (nodejs)
Im trying to connect to my database. Its working if i use mongodb compass but then im using mongoose to connect it doesn't work.
I keep getting this error:
Mongoose connection error ...
0
votes
0
answers
54
views
image turns to undefined after rendering successfully
image turns to undefined after rendering successfully. I retriever the images from database successfully, and it turns to undefine. I don't know why this is happening.
this is the cart page
"use ...
0
votes
2
answers
258
views
MongoNetworkError: AggregateError has an empty errors array
I have a health check endpoint in my application which simply pings a mongo reserve cluster. But for some reason I frequently get this error log on the health check endpoint.
MongoNetworkError: ...
0
votes
0
answers
36
views
express-session shows 'req.user.user' as undefined
I am using NextJS for the frontend and ExpressJS for backend, and I am kind of new to this technology and backend in general. When using express-session with MongoDBStore, I have an issue when saving ...
2
votes
0
answers
41
views
express-mongo-sanitize - Cannot assign to read only property 'query' of object '#<IncomingMessage>'
This is on a web app which is built using MEAN stack.
Node version 20.18; Ubuntu 22.04; Angular 17.x (the dist file is served from within the Node project.)
When the web-app URL is visited. It ...
0
votes
0
answers
40
views
MongoDB populate sporadically not working for same dataset
I am facing this issue where I have appointments and customers and contacts and while getting an appointment I am using populate to populate the customer from appointment,
The issue is it has been ...
0
votes
1
answer
36
views
MongoDB recursively get documents using multipe fields
Using Mongo 6.0 in a NodeJS application, I have a collection where each document can have an array of mandatoryCourseIds or electiveCourseIds or both.
A sample could look like this:
[
{
&...
1
vote
1
answer
60
views
I can't upload images to MongoDB through Postman/Thunder Client
So when I try to add a product for an E-Commerce website project, all the details of the product are successfully transferred to MongoDB except the images, where I get an empty array instead.
This is ...
0
votes
0
answers
38
views
Authentication failed. Auth is enabled via mongod.conf, but login without a password is still available, but with a password it is not possible
I'm trying to deploy a NodeBB forum, but I'm facing an authorization error (mongodb). I thought about just switching to redis, but it's stored in RAM.
Debian 12, Localhost, Apache (I also deployed ...
1
vote
0
answers
62
views
Why am I getting the error Cannot read properties of undefined (reading 'findOne') when trying to add an address to a user?
I'm working with a Node.js application using MongoDB and Mongoose, and I have two models: User and Address. I am trying to add an address to a user, but when I try to call findOne on the Address model,...
1
vote
0
answers
31
views
FindOne result is showing as null with ObjectId
Overall, the FindAll function is working as intended. The main issue comes into play with the FindById function. This database was made a few years ago, just redoing the project now.
I've tried ...
0
votes
1
answer
40
views
Getting Validation Failed: Path is required Error even when I am providing all the required data
I am using Mongoose in my Nodejs application and I want to create a new Experience collection. For that I am providing all the data in Postman. I am using application/x-www-form-urlencoded to send my ...
1
vote
1
answer
33
views
A declared function is not working in login route in express.js
I'm working on a project where I'm creating the login and registration functions of the website. Registration is working but in the login section, the given password and the password stored in the ...
0
votes
1
answer
68
views
Performing calculation over huge dataset in mongoDB with nodejs express.js in backend code | Optimising time and memory
I have to create connections over 700,000 flights data.
This is the schema of flights
const flightSchema = new mongoose.Schema(
{
date: {
type: Date,
},
flightName: {
type: ...
0
votes
0
answers
45
views
mongodb and nextjs connetion problem GET http://localhost:3000/api/movies 404
i created a cluster in mongodb atlas it had some dummy data like this
"sample_mflix(movies(title, runtime, year))"
and i want to display it on a table, here is the code for the component ...
0
votes
0
answers
45
views
Cannot connect my Node.js Backend Server to MongoDB on Vercel
I have a React/Node.js project where I am deploying only the backend (server folder) to Vercel. The backend is hosted correctly on Vercel, and I can confirm this with a simple API test I made in ...
0
votes
1
answer
47
views
req.user is undefined in passport.js/express/mongodb application
I have implemented a basic passport.js authentication on top of an expressJS/node application. The user auth is working fine, but I would like to be able to store specific additional data for each ...
0
votes
1
answer
38
views
Node Gives Connection Failed
When I run my node.js code, it gives me following error,
I have connected the MongoDB database with this code. But now it shows as connection failed.
I have installed nodemon and express.jsin this ...
-1
votes
1
answer
95
views
Strange : MongoDB Connection Failed: connect ECONNREFUSED ::1:27017 [duplicate]
I have already gone through all the solutions provided for this issue and attempted to resolve it. However, everything seems to be working fine on my PC—MongoDB services are running without issues, ...