Category "mongoose"

How to find documents based on the result of a function mongoose

So I have two schemas user and driver they both have latitude and longitude attributes. At some point I want to query the database for nearby drivers, I will be

How to add attribute to the result of mongoose query before res.status(200).send(result);

I am trying to build a CRUD API that query a mongodb. I want to add another attribute (temperature) to the query result before sending it back to the client. Pa

Mongoose.connect is not connecting to local db

I'm building a simple MERN blogging app with a local MongoDB. Everything was working fine until yesterday. I literally changed nothing at all and now I can't co

Remove Embedded Documents in an Array in MongoDB with mongoose (updateOne - $pull) not work

I have an app with MongoDB (Mongoose) in NodeJs. In a collection I have this type of documents, defined by weeks: { "_id": {"$oid":"617f3f51f883fab2de3e7260"},

"Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0" ERROR -- NodeJS, MongoDB, React Application

I'm trying to fetch an array from my user database from my react app. The response I'm getting is an HTML file, but I'm not sure why it's not working as I have

MongooseServerSelectionError: connect ECONNREFUSED ::1:27017 wont get fixed

I've been trying for over 2 hours now trying to figure out what's wrong with this database. I've tried everything. From reinstalling the server, restarting the

eventlistener not functioning when post request is sent

I am trying to add a number indicator to my cart icon that will display the number of items added after the product has been saved to my database. <div class

How to find Average of star Rating in mongoose

I have working on my final year college project On MERN stack. my problem is mentioned bellow please help me. const Organization = mongoose.Schema({ name: {

Jest database setup before any test suits are run

I'm trying to seed my entire database for all the necessary resources that need to be present to test my API successfully. My tests are in several files. How ca

MongoClient not connected error while trying to use Mongoose?

As part of my course I'm learning mongodb and now Mongoose. I've written the code exactly as done in the lesson but when trying to start it with node app.js I g

MongoDB aggregate and then flatten

FULL DISCLOSURE: I'm a MongoDB noob I'm dealing with a legacy DB structure. A part of my MongoDB looks like this currently: Events (_id, name (string), ...) Ord

Nestjs unit test: TypeError: this.userModel.findById(...).exec is not a function

using nestjs framework and with a repository class that uses mongoose to do the CRUD operations we have a simple users.repository.ts file like this: @Injectable

Multer GridFsStorage Dynamic Configuration for Multiple MongoDB Connections

So I'm using MongoDB Atlas, Mongoose, Multer and GridFsStorage to upload files to a single database on the cloud which works fine, but I want to be able to uplo

Mongoose and Next.js: Unhandled Runtime Error TypeError: Cannot read properties of undefined (reading 'Token')

I basically defined this Model, much like another which doesn't error out; So I am stumped as to why it's not working... Here is a Minimal, Reproducible Example

I want to find the last object which i'm posting in my database without any condition but i can't find any method for that

Data.findOne({}).then((respp)=>console.log(respp, "find one")) Like I have this method this is returning First object and if I apply a condition then i can

How to sort data based on entry of parent collection in mongodb using mongooose package

How to sort data based on entry of parent collection in mongodb using mongoose package. My schema is organised as given below Profile Schema const mongoose

How to implement transactional management in mongo with graphql?

I'm currently working on a movie database with graphql and mongodb. When a new review is added I want to push the review id immediately to the reviews array of

Error: querySrv ESERVFAIL _mongodb._tcp.cluster0.abcd0.mongodb.net

My nodejs app was working fine with mongodb connection and suddenly this error got appeared. Then I tried to connect to mongodb with mongo compass and same erro

How to use two schemas to create two collections in mongoose

I'm storing some data I'm getting from API calls in a collection ('Asin'). - work just fine. I build two pages -register & log in, installed all relevant bc

Heroku Error. Cannot find module 'Mongoose'

For some odd reason (i have been deployed on Heroku for around 1.5 years) my instance decided to throw a weird error regarding not finding 'mongoose' after atte