I am using moment from mongorc.js (reference: https://raw.githubusercontent.com/gabrielelana/mongodb-shell-extensions/master/released/mongorc.js) when executed this small snippet its printing “invalid date” But in Java: Prints Sun Nov 30 00:00:00 IST 2 Though may not be correct, I want not “…
Tag: mongodb
How to Mongoose send different value on find of specific field
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
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 dupli…
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…
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̶…
Can’t upload picture to MongoDb from React frontend
I’m creating a tinder clone, I can create a user fine however I cant upload a picture. The error I get is ValidationError: User validation failed: pictures: Cast to embedded failed for value “‘picture’” at path “pictures”. I’m not sure what I’m doing wrong. The …
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 se…
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? A…
DiscordJS ticketinfo TypeError: results.transcripts is not iterable
I’m making a ticketinfo command that get’s information about a ticket that’s in my database. I’m trying to catch the information from the database and put in into my embed. The embed is being send to the user that runs that command. It seems to not work. Why isnt it working? My Code: E…
How would I access the values of the coordinates through a NodeJS MongoDB query?
Here is my query: const ships = await ais .aggregate( [{ $match: { MMSI: 219022256 } }, { $sort: { Timestamp: -1 } }], { allowDiskUse: true, } ) .project({ _id: 0 }) .limit(1) .toArray(); Answer considering the returned values you have an Array of objects (JSON objects) at your disposal, so you would be able …