Wednesday, 19 February 2020

How to insert JSON object values into MongoDB using Mongoose?

I am using npm article-parser library to parse through articles and retrieve the content. The parser retrieves title, date, source, body etc in JSON object format. The problem is, I am already retrieving a few of these details from another source and setting it using bulk $set into my MongoDB.The only two fields I want to set from the article parser are source and content and I'm not sure how exactly I could do it. I tried to do .field to access the values inside the object but I am getting undefined and null when I console logged it.Here's my code -https://codesandbox.io/embed/clever-bartik-4oec2?fontsize=14&hidenavigation=1&theme=darkThere are some errors showing because it's not connected to my DB, and some packages haven't been imported. My whole project is pretty big so I am only uploading this one file. The rest aren't really relevant.The problem is near getArticle and even when I try to push the values into the DB near $set

Submitted February 20, 2020 at 05:34AM by pappermanfan

No comments:

Post a Comment