Category "mongoose"

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

Typegoose not working with vuetify in electron

Im trying to build a very simple model with typegoose inside Vue + electron. This is my simplified code: import { getModelForClass, prop, modelOptions } fro

Mongoose ValidationError makes Express Server crashed

I have struggled with this problem for many days. Whenever I make an invalid POST request, it throws me an Error. Sounds good but when I cancel that request, th

Mongoose ValidationError makes Express Server crashed

I have struggled with this problem for many days. Whenever I make an invalid POST request, it throws me an Error. Sounds good but when I cancel that request, th

how to solve Prototype Pollution issue in VS code

I installed a package that is related to my learning courses. the codes are released on 2018 and I updated all the versions on package-lock.json and package.jso

Exceeded timeout of 5000 ms for a test with Jest and MongoDB

I'm trying to implement database population by using a migration function. The code works perfectly, it saves all the data into the database, but the test for t

How to store and retrieve checkbox state on refresh of page? Mongoose/EJS/Nodejs/Express

I have a checkbox, essentially like a to do list. When i check the box, I want to retain the state even after i refresh the page by using mongoose. I do know of

Boost search score from data in another collection

I use Atlas Search to return a list of documents (using Mongoose): const searchResults = await Resource.aggregate() .search({ text: { query

Remove certain fields from the mongoose HydratedDocument

When we lean the documents, the id property is still included which is undefined and can cause unexpected errors. To simplify this for my team, I want to remove

Can't populate Mongoose schema on express route

So I want to populate two things and return them in the response, I want to return an array of images and the author. However the response returns nothing, if I

How to remove schema validation in mongoose (mongodb)?

I have MongoDB server version: 5.0.6 installed and used "mongoose": "^6.0.14" to create a model validation. Example of model: const User = new Schema({ name:

NextJS: load global plugin in Mongoose before model creation

I have a folder structure looking something like this root/ pages/ models/ User.js utils/ plugin.js dbConnect.js I want to be able to load th