3,365 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
1
answer
49
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 ...
2
votes
0
answers
147
views
MongoDB Atlas connection error: queryTxt ETIMEOUT with Mongoose
Mongoose connection to MongoDB Atlas fails with queryTxt ETIMEOUT
I’m trying to connect my Node.js app to MongoDB Atlas using Mongoose, but the connection fails with a timeout error.
Here’s the error ...
0
votes
0
answers
75
views
Possible to add default class to a mongoose Schema?
A of class="active" is added based on what star I click on. With schema, how do I connect it to the db, creating a default 1 star to every post? Tried to do it with "score:" but ...
0
votes
0
answers
44
views
Mongoose populate plugin with Typescript
I've been trying to create a plugin which implements a query and schema method that populates a user field and selects some inner fields from it (firstName, lastName, image).
I just can't seem to make ...
0
votes
1
answer
79
views
How do associate created documents with a user using Passport JWT in a MERN app?
I'm building a MERN stack application where users can create travel logs. I'm using Passport JWT for authentication. When a user creates a travel log, I want it to be automatically associated with ...
0
votes
0
answers
29
views
How do I change existing string type property into reference type property?
There is an existing collection1 having a property which is an id of another collection2 but the data type is string. How do I convert this property to an objectId type with reference to the other ...
0
votes
1
answer
89
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
0
answers
37
views
How to manage a field in mongodb that references a referenced schema?
I have a collection named ‘policies’ which references control in its field 'associatedControls' from collection ‘controls’ and control has a field 'associatedFrameworks' where it references 'framework'...
0
votes
0
answers
40
views
Populate in Mongoose doesn't work if I'm using Typescript Error: Schema hasn't been registered for model "Category"
I'm using NextJs 15 with TypeScript and Mongoose, but when I try to populate the Product fields with the category, I get the following error: Error: Schema hasn't been registered for model "...
2
votes
1
answer
115
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 ...
1
vote
0
answers
75
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,...
0
votes
0
answers
67
views
Mongoose server error! Backend connection not working only in the particular system
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. Make ...
1
vote
0
answers
42
views
Can not use $rename to rename property of documents
I have a mongoose Schema and I would like to rename a certain property named 'template' to 'document'.
If I would first change name of the property from 'template' to 'document' in the Schema and than ...
0
votes
0
answers
36
views
Cannot rename field in Mongoose without breaking geospatial functionality
Synopsis
I want to rename the 'address' field to 'location' in my Mongoose schema. The location field only stores address data, such as street, city, postcode, etc. The locationGeo field, on the other ...
0
votes
1
answer
53
views
How to use enum with values in Typescript?
Note: I'm a beginner level person in typescript, so, instead of downvoting my question, please try to elaborate the concept.
I'm having trouble using enum in my code. I want to use an enum(with values)...