I’m running MongoDB Atlas on node express and I got this error when I tested with postman. This is my .env, I’m guessing the problem might be here too, Kindly help: Answer In my case, I had to go to Atlas, and reset my whitelisted IP to the correct address. Then I restarted my local server and tri…
Tag: mongodb
Booking reminder Nodemailer node-cron MongoDB
I am having problem sending a booking reminder email. I use nodemailer and node-cron. It works good. I would like to read date from database and e.g. send email one week before reservation. I have no idea how to do it. My model: I think start time parse to date? How read only this reservation which will be in…
How to return object from MongoDb database in findOne method
sorry if it’s easy mistake, I’ve not so much experience in JS, I’ve tried a lot of ways and I can’t resolve this problem. I can find and print my object from database, but I can’t return it to my main method. My main method (it’s in another file than methods to database): a…
How to group by sub documents and get unique value of value field?
This is my database collection: Now I want to send the data of only the attribute where isVariation is not 0. Also I want to send the variant values of each attribute where isComplete =1. Hence the result should look like this The above result does not have value of 2.5 inch as the isComplete is 0 for this do…
How to return the variant values of each product if that product is a variant?
I have a database in MongoDB like this Now I want to return data where 500 GB has been in productId 1 and 3 The response should be like this: I have the possible values that I store in another collection for variantPossible values. The values that i am storing are like this: I want to return the variant value…
How to query on collection values and referenced documents values in MongoDB?
I don’t know how correctly I formulated the question. I need to execute a query on both the values of the collection and the values of the referenced objects. The original collection looks like this: When executing a query that meets the condition district == “Texas”, I need to get the f…
Match based on a field only with non-empty array
I am trying to do a filter on something. Here is a simplified layout of my Order model: I want to query the documents based on the ingredients that they contain. I have an array of items to search through “objectifiedIngredients”. If it has ingredients in it, then I want to search for orders that …
Using method defined in the constructor after querying document from database
UPDATE ( ANOTHER SOLUTION) What I was looking for, I found out later, was the possibility of making the method static. Then I can apply the method independently from the class. Supposing I defined the following contructor: After fetching the User via CRUD operation (ex, findOne), I get an object back, the one…
Push object to array in mongodb nodejs [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question This is my mongodb collection. I want to push object to array with findOneAndUpdate(). This …
Mongoose Subdocument in another Invalid Schema error
I have 2 separate files, one encapsulates the Slot Schema, and another for the Location Schema. I’m trying to have a field in the Slot Schema that references the location Schema. In a separate File: I get this error when I run : I’d really appreciate it if you’d help me figure out why the co…