I’m working on a program which scrapes all the telegram messages, but we found out we needed a simple way of inserting and reading data(crud). I chose functional programing because oop is too imitating and too complex for me(if anyone has suggestions please hit me up because I don’t know where to …
Tag: mongodb
Transform JSON array using ES 6 methods
I have the following example of an array format that needs to be transformed. It needs to be transformed like this… I’ve tried various iterations of map and reduce. Gotten close, but not completely there. This is in a Vue project. Here is an example of what I tried. This returns: I cannot figure o…
TypeError: cb is not a function in nodejs?
(node:13384) UnhandledPromiseRejectionWarning: TypeError: cb is not a function I am using passport js for authentication for my website, I am able to get all routes but when I try to sign up that is post router so in the console I am seeing these err, my data saved in DB but after posting my page loading cont…
collection.find({}) doesnt work after many tries
I am building an api with express and mongoose and im usingdb.collection(collection).find({}) expecting that i get all of my docs back (3 test docs in total) as seen from tutorials. It doesnt give me any errors when im executing a req from postman and that confuses me as im geting nothing, not even an empty o…
change only one field of entire array of embedded document in mongoose
i have a list schema and a question set schema. the quetsionSet schema is embedded inside the list schema. its working fine but how can i update anything inside the array of embedded document i.e. here i want to change the listname of all the documents inside questionSet (array of questionSet documents). here…
update two layer nested object based on the id
I have this structure in my Mother Model (this is a fixed structure and I just push cards or update them on these 3 array levels): The Objects inside cards.advanced array above are like: Assuming I have access to Mother model like this: How can we update a card object based on its id and the level it belongs …
TypeError: Cannot read property ‘0’ of undefined in post method in nodejs
I am new to nodejs and mongodb. I am trying to create simple to-do app with nodejs and mongodb. I have added the task in database. Now in post method, I am using insertOne method of mongodb and in res.json I am having the following error. res.json(info.ops[0].data) TypeError: Cannot read property ‘0R…
Mongoose error: “Topology was destroyed”, what’s the problem?
I was coding a leveling system for my discord bot, but encountered a mongoerror on the way, does anyone know why this is occuring? (The addXp function runs whenever someone chatted, the error is logged in the removeTimeout function.) I have used mongoose in many more ways in my code but this hasn’t yet …
Mongodb positional operator is not working
When I am trying to update just “title”, it is working fine, but if I am trying to update the nested object in the array, it is not working. Data: Data Working: Not working: Answer Demo – https://mongoplayground.net/p/caFBz-lx8dQ Use $[] The filtered positional operator $[] identifies the ar…
Mongodb Insert dynamic unique keys to nested object add if not exist else update
I need to operate something same as how $addtoset works for arrays in mongodb but for an object,Im adding dynamically generated objects to an object. The dynamic key is based on a string which will help to maintain a unique value so another key will not inserted with the same dynamic key. i tried $set which a…