46,634 questions
1
vote
1
answer
153
views
MongoDb Connection failed : Error: querySrv ECONNREFUSED
MongoDb Connection failed : Error: querySrv ECONNREFUSED
How can I solve this error? My node v24.13.0 and mongoose 9.1.5 are the latest versions. Also I changed my network dns to Google's dns number ...
-1
votes
0
answers
45
views
This expression is not callable. Type 'SaveOptions' has no call signatures. in pre("save") hook. TypeScript with Mongoose
I am working on one of my personal project and using Mongoose with TypeScript. I'm trying to add a pre("save") middleware to hash a password. But I am getting an error.
I am using Node.js ...
5
votes
1
answer
195
views
MongoDB Atlas SRV connection fails with querySrv ECONNREFUSED after switching Node versions (Node 22, Windows)
I’m running into a MongoDB connection issue that only appeared after switching Node.js versions, and I haven’t been able to resolve it despite extensive troubleshooting.
Environment
OS: Windows 10
...
0
votes
0
answers
47
views
Sorting problem in mongoose while sorting through query parameter [closed]
the code is working properly when i fetch normal data or try to fetch data based on condtions like less then or greater then all these are working properly
but when i try to sort the data that is not ...
0
votes
0
answers
39
views
Property [bsonType] is missing in typescript interface, when trying to generate mongoose compatible in typescript
I'm trying to generate a compatible type for Mongoose/bson ObjectId for a part of my repo which holds types which is shared between my Frontend and my Backend.
I don't want to install/load mongoose or ...
3
votes
0
answers
70
views
How to check if a document is mongoose sub schema in middleware?
I am building a multi-tenant application, and I am using a global plugin instead of adding a plugin to each model one by one. This plugin will handle adding organizationId during filters, saving, and ...
3
votes
1
answer
45
views
Why is Promise.all not supported inside MongoDB (Mongoose) transactions?
I’m using MongoDB transactions with Mongoose, and I noticed a warning in the official docs that confused me regarding concurrency.
According to docs for ClientSession.startTransaction():
IMPORTANT: ...
1
vote
1
answer
103
views
Error when implementing auto-increment functionality using 'mongoose-sequence': "TypeError: next is not a function."
I am having trouble with the implementation of the mongoose-sequence library in my MongoDB, Express, Node.js API.
This project is one for adding people to a database. Each person has a firstName, ...
0
votes
0
answers
62
views
Mongoose intermediate data saving in DB
I have a branch management system in my application where some approved requests show the processor's name (like "usernme") while others show "Legacy".
The issue
Logs always show ...
2
votes
1
answer
117
views
Typescript error using next() with mongoose .pre method
I am working on an authentication project using Typescript and mongoose as my database. Whilst writing my middleware code that should hash the password before it gets inserted into the mongoose ...
2
votes
1
answer
57
views
Mongoose Model.save() not working inside a loop
I'm working on an Express controller to update product's inventories when saving an order. Below is the code to recalculate sold & sellable amount of a product.
for (const lineItem of order....
2
votes
1
answer
90
views
I am saving some user data but i see MongoDB duplicate key error on a field i havent declared [closed]
I'm losing my mind a bit here. I'm completing an old project of mine with Express and Mongoose with Google firebase login. Everything was working fine with my first test user, but as soon as I tried ...
-1
votes
1
answer
63
views
Error in plugin passport-local-mongoose: "schema.plugin should be function not an object"
const mongoose = require("mongoose");
const passportLocalMongoose = require("passport-local-mongoose");
const userSchema = new mongoose.Schema({
Fullname: {
type: ...
2
votes
1
answer
97
views
How to combine diacritics-insensitive, case-insensitive and partial search in MongoDB?
I'm trying to implement a robust search function in my NestJS/Mongoose application that can handle partial matches while being case-insensitive and diacritics-insensitive (ignoring accents).
My ...
3
votes
1
answer
66
views
Query not printed as expected
exports.getAllProducts = async (req, res) => {
try {
console.log(req.query);
const queryObj = { ...req.query };
const excludedFilters = ["page", "limit", "...