I would like to use JSON formatted objects from a .txt file to save them into my MongoDB database. I have a Node.js API with a method for adding the item and I also use Mongoose for easier data management in my Node.js API. I have no idea where to start.
My JSON string that represents an object I would like to save into the database for example looks like:
{ "title": "test", "poster": "test...", "rating": 10.0 }
Is there a (fast) way to read a txt file line by line, convert this string into an object and save it into the database like: object.save(...);
using Mongoose methods? Thank you.
via Luki
No comments:
Post a Comment