Reputation: 25
i want to do a node.js script that goes through my mongo.db and checks if the url doesn't match with the url in my other database. As of right now, i have json with over 750k scam websites and i need to import it somehow to the database. Does anyone know any quick way to do it? I tried:
for (var i = 0; i < files.length; i++) {
var file = files[i];
var link = require("./files/" + file);
var newLink = new rescamdb({
link: link,
createdAt: Date.now(),
});
newLink.save();
console.log(`
🔧 Added new link to database
`);
}
But it doesn't work, won't even create the database and then it fails on validation error. The json file isn't mongodb ready, it looks like this:
[
"scamsite1.com",
"scamsite2.com",
"anotherscamsite.com",
"scamsite4.com",
...
Upvotes: 1
Views: 172
Reputation: 25
Converted my JSON so it looked like:
[
{"link":"somescamwebsite.com"},
...
]
and then imported it to the mongo by mongoDB Compass
Upvotes: 1