I have a field which contain url to an image which is protected. It needs a secret to access file and the secret expire after a time. I want that when I do Mode.find() then the url value get replaced by anther url which contains the secret. So, that I don’t have to manually every where I find from the
Tag: mongoose
Everything is fine but logout doesn’t work – (Cannot POST /logout)
My logout doesn’t work and I’m trying to figure out why. When I click on submit it says : Cannot POST /logout I have used passport to check for data from the users and I have create route for each webpage. I have tried many things but I think the problem may come from the form on the action side.
Passport.js Multiple login system is not working correctly
I am getting a weird error as all of my login system are working correctly which include local login in system and Google and Facebook login. The problem arose when I try to try to register with google when I have already register the Facebook account and I try to register Google account it gives E11000 duplicate key error collection
Impossible to query nested mongoose array?
I want to Query and array with regex inside and mongoose (mongoDB) model. I want to search inside the nested array of the Productmodel : The model inside the “suppliers” array is: Now here’s the problem, if i query and and populate() i get all the results. But for some reason I cannot search inside the Array containing several suppliers.
I am trying to use populate in mongodb with nodejs, but values are not populating
listservices.model.js Services.model.js exports.findAll = (req, res) => { const services = req.query.services; var condition = services ? { services: { $regex: new RegExp(services), $options: “i” } } : {}; Services.find(condition ).populate(‘servicescategories’) }; [{“_id”:”60a27c66d87174379c93d7b5″,”name”:”MY data name”,”closed”:false,”active”:false,”listservices”:”60a2606680405c41c05cf005″,”createdAt”:”2021-05-17T14:23:34.412Z”,”updatedAt”:”2021-05-17T14:23:34.412Z”,”__v”:0}] Answer You are trying to use different name in your controller, populate receives 4 parameters- path, selection(fields to be return) , condition, options (like {limit:10}):
Return statement of a function doesn’t get triggered after using it in Express FileUpload .mv() method
I’m trying to upload a file through Express File Upload but getting an undefined value of the function in which it is being called. I have this function which checks if the user chose a single file or multiple files. To keep it simple I am just going to show the issue in single file upload. That is req.files.fileInput is
Ignore $in if empty array is provided
I have the following model: Note: interface matches the model exactly but i pasted this as its much shorter. I am using the following data to filter through this collection: What i want to achieve is to find every document and check if the corresponding array has at least one of the values from the array i sent via includeFilters.
Handling Mongoose Query Errors in Express.js
So let’s say I want to make a Mongoose query to a database, inside of an Express post route: My concern is the handleError function. I’m not quite sure what kind of errors could even happen in Mongoose since it’s just a simple query, but what should be included in the handleError function? And what response should I send to
Mongo shell query is not working on mongoose
I have written a shell query which works perfectly on mongo shell but is not returning any value when run using mongoose in nodejs + typescript; Mongo shell But when I run the same query using mongoose in one of my routes. Mongoose : I would really appreciate if someone could help me with this. Because it took me a
MongoDB/Mongoose – Find all where a specific Date is in a Date Range
for example I have documents with this field: and I want to get all documents where a specific date (like today) is in the date range. Is it possible to make such a query? For example if I search for 18th April, then I get that document. I thought something like this: But this doesn’t work… I get an error