46,653 questions
-1
votes
1
answer
50
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
89
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
63
views
Query not printed as expected
exports.getAllProducts = async (req, res) => {
try {
console.log(req.query);
const queryObj = { ...req.query };
const excludedFilters = ["page", "limit", "...
0
votes
1
answer
62
views
Custom error objects for Mongoose schema paths
Take the following Mongoose schema.
const userSchema = mongoose.Schema({
username: {
type: String,
required: true,
unique: true,
minLength: 3
},
name: ...
0
votes
0
answers
17
views
Mongoose Virtual Not Populating in MERN Stack Despite Correct Schema Setup
//User Schema
const userSchema = new mongoose.Schema({
name: String,
email: String
});
userSchema.virtual('posts', {
ref: 'Post',
localField: '_id',
foreignField: 'author'
});
//Controller
...
2
votes
1
answer
89
views
Should I close the DB connection in NextJS
I am new to programming (and NextJS) and I'm building a NextJS app, using Mongoose for my MongoDb connection. I was wondering if I should close the connection after each query? Right now I am just ...
-1
votes
1
answer
56
views
Mongo unexpected mongo queries
i have some problems in production using mongo
We have python using mongo and mongo-express for ui. And we are facing performance issues, after research i found db.currentOp() to see queries which are ...
0
votes
0
answers
23
views
findByIdAndUpdate doesn't work with discriminators
I have these two schemas with discriminator. It's custom activity that also has fill in the gaps questions which is another schema. For some reason when I use findByIdAndUpdate, it updates all the ...
0
votes
1
answer
67
views
MongoDB query with Mongoose - Matching subdocument attribute within an array
I am trying to solve an issue with the format of documents in a MongoDB depicted below.
{
"_id": {
"$oid": "68dc4f78e11553b3647231e2"
},
"name": "...
0
votes
1
answer
43
views
Using mongoose discriminator in an Nextjs app throws OverwriteModelError even if the cached value is used
While defining the model, discriminators are created on the basis of the SchemaVersion. On export, the already created discriminator model is returned to prevent the overwrite errors from mongoose ...
0
votes
1
answer
55
views
MongoDB - Cannot get nested document by _id
When I execute the following code in my application:
const freelancer = await Freelancer.findOne(
{ _id, 'experiences.title': 'Frontend Javascript developer' },
{ 'experiences.$': 1 }
);
console....
0
votes
0
answers
70
views
ValidationError: MyModelSchema validation failed: items.0: Cannot read properties of undefined (reading 'model')
I am working on migrating the project to a new version. Stack: express 5, mongoose 8, typescript 5.8, typegoose 12
I looked for more information and would now like to clarify the cause of the problem:...
0
votes
0
answers
72
views
Mongodb $push $each onto array is resetting createdAt date for all subdocuments
Hopefully this makes sense. Using mongoose to push new items into an array of subdocuments, the documents get added fine, however on certain (random) occasions, the createdAt date of the current ...
2
votes
1
answer
103
views
How to use a virtual property based on foreign data in nestjs/mongoose?
I would like to know how to use @Virtual from nestjs/mongoose to calculate a local field with fields from another schema (like a classic mongoose populate)?
I have this InvoiceHub schema that ...
0
votes
1
answer
52
views
Mongoose - unknown operator: $text
I have a mongoose schema where I defined a text index like this:
FreelancerSchema.index({ title: 'text', presentationText: 'text' }, { weights: { title: 2, presentationText: 1 } });
I try to search ...