skip to Main Content

Unable to connect to Mongodb from Nodejs

I am trying to connect to Mongodb from my first node project.I am using Mongoose to achieve that. However, mongoose.connect() gives me MongoParseError error. Complete error: MongoParseError: options connections, models, events, __driver, options, _pluralize, schema, model, plugins, default, mongoose, cast,…

VIEW QUESTION

How can I retrieve image from mongodb

in mongodb my image is saved as image: BinData(0, 'QzpcZmFrZXBhdGhcV2hhdHNBcHAgSW1hZ2UgMjAyMi0xMi0wNCB40Ny4zMS5qcGc=') I am trying to access this image in my frontend Reactjs like this {userData.image ? <img src={data:image;base64,${userData.image}} alt="User profile image" width="200" height="200" /> : <img src={'./Images/profile.png'} alt="Default image" width="200" height="200"…

VIEW QUESTION

Mongodb – Unable to get document using document.findOne()

I tried to get a document using document.findOne() but it's value is showing undefined . Here is my code `app.post("/studentlogin",(req,res)=> { let password; console.log("login page"); bcrypt.hash(req.body.password,saltRounds,(err,hash)=> { const user= Student.findOne({srno:req.body.srno}); console.log(user.srno); if(req.body.srno==user.srno && hash==user.password) { session=req.username; session.userid=req.body.srno; res.redirect("/"); } else{…

VIEW QUESTION

String version of MongoDB WithID typescript generic

The WithId generic that comes with Mongo's typescript library is highly useful in scenarios where you don't want to modify your existing interface/type for use with MongoDB such as: export class TagsCl { private publicTags: Promise<Array<WithId<ProductTag>>>; private allTags: Promise<Array<WithId<ProductTag>>>; private…

VIEW QUESTION
Back To Top
Search