I have a collection that has document structure like following: Mongo PlayGround As you can see, each document has basicDetails object and a tasks array. Each task contains some properties of its own and a subtasks array. I want to update subtasks’s description from ABC to XYZ where root level id is 1, …
Tag: node.js
Unescaped Characters when using languages other than English in Node JS?
I am using a Google cloud function with the Google Places API. It works fine in English, but I get this error when inputting Hebrew or Russian: When I try my request directly in a web browser it works fine: But when I try the exact same string in NodeJS I get the error above, here is my code (I
How can i calculate local time in node js
I want to do send a automated email from by backend with a date stored in my db. But the db consists of UTC date. I wanted to convert it to local time for the user sending the email. What i thought of was, i can send a offset while making the API call. i.e new Date().getTimezoneOffset() and i add
Webpack – Typescript – Babel Loader not transpiling JSON import
Setting up a new webpack build for my local setup to use across the system. Aka building my webpack setup as a private node package as all my work is literally the same so building it as a global package. Similar to the concept of laravel mix. Anyway, I’ve gotten the webpack setup transpiling the Typesc…
heroku and nodejs erorr (Web process failed to bind to $PORT within 60 seconds of launch)
I am using discord.js and I have a code where if someone votes for my bot on https://top.gg the bot will send a message, but it got this error Here is my code: Please help me that would be very appreciated Answer Heroku changes the Port that runs Node Application from time to time. Try changing your webhook p…
Is there any way to get value in node js server while clicking on div
Here is my EJS file Html view here My routes are in the below route:- SO here I want, whenever I click on any of the div I want to print the mac id in log from the respective div in plugDashboard section. So is there any way to do so? I searched for many solutions none of them were
Mongoose update replace entirely former document
I’m trying to update my document to remove a few fields I am testing onto further on in the frontend, I removed the fields with this: Thus when I look at it before my mongoose findByIdAndUpdate it has indeed none of these fields then I’m trying to update like so: But when I use the overwrite optio…
Bufferizing data from stream in nodeJS for perfoming bulk insert
How to bufferize efficiently in nodeJS on events from a stream to bulk insert instead of unique insert per record received from the stream. Here’s pseudo code I’ve got in mind: Does this look realistic? Is there any possible optimization? Existing libraries facilitaties that? Answer I ended up wit…
ReferenceError: require is not defined MongoDB
I’m trying to connect to my MongoDB database and I’m getting this error Answer You are attempting to use require() inside an ESM module (you can see the Object.loadESM in the call stack of the error) which tells us it’s an ESM module. You can’t use require() in that type of module. Ins…
Can you declare your own function in Discord JS?
Normally I just add to the command files or the index file easily but it’s starting to look messy. Recently I got this leveling system working I would like to be able to put this into its own function and then call it in the “message” section for every time someone sends a message. Is that p…