-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#16 metascraper integration
- Loading branch information
Showing
326 changed files
with
540 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const mongoose = require('mongoose'); | ||
let db = require('./database.js') | ||
|
||
mongoose.connection | ||
.once('open', () => console.log('Connected to DB')) | ||
.on('error', (error) => { | ||
console.log("Your Error", error); | ||
}); | ||
function clearDB() { | ||
db.metaModel.deleteMany({}).then(function(){ | ||
console.log("Data deleted"); // Success | ||
mongoose.connection.close(); | ||
}).catch(function(error){ | ||
console.log(error); // Failure | ||
}); | ||
} | ||
// Resets all entries with updated value true to updated value being false | ||
function resetUpdatedVar() { | ||
db.metaModel.find({'updated': true}, async function (err, docs) { | ||
if (err) return console.log(err); | ||
await db.metaModel.updateMany({}, {'updated': false}); | ||
console.log("Data reset to updated = false") | ||
mongoose.connection.close(); | ||
}); | ||
} | ||
let arg = process.argv.slice(2)[0]; | ||
console.log(arg); | ||
if (arg == 'clear') { | ||
clearDB(); | ||
} | ||
else if (arg == 'reset') { | ||
resetUpdatedVar(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"nytimes":["https://www.nytimes.com/live/2021/01/07/us/capitol-building-trump?action=click&module=Spotlight&pgtype=Homepage","https://www.nytimes.com/2021/01/07/technology/trump-social-media.html","https://www.nytimes.com/2021/01/07/us/now-it-can-be-told-how-neil-sheehan-got-the-pentagon-papers.html","https://www.nytimes.com/2021/01/07/style/archives-hashtag-party.html","https://www.nytimes.com/2021/01/07/opinion/capitol-riot-trump-america.html?action=click&module=Opinion&pgtype=Homepage"],"cnn":["https://www.cnn.com/2021/01/07/politics/trump-biden-us-capitol-electoral-college-insurrection/index.html","https://www.cnn.com/2021/01/07/politics/law-enforcement-capitol-riot/index.html","https://www.cnn.com/politics","https://www.cnn.com/2021/01/07/politics/georgia-senate-runoff-loeffler-warnock/index.html"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"https://www.aljazeera.com/":[],"https://www.cnn.com/":[],"https://www.nytimes.com/":[],"https://www.aljazeera.com/news/":[],"https://www.aljazeera.com/africa/":[],"https://www.aljazeera.com/middle-east/":[],"https://www.aljazeera.com/latin-america/":[],"https://www.aljazeera.com/asia/":[],"https://www.aljazeera.com/us-canada/":[],"https://www.aljazeera.com/live":[],"https://www.aljazeera.com/asia-pacific/":[],"https://www.aljazeera.com/europe/":[],"https://www.aljazeera.com/features/":[],"https://www.aljazeera.com/us-elections-2020/":[],"https://www.aljazeera.com/economy/":[],"https://www.aljazeera.com/opinion/":[],"https://www.aljazeera.com/investigations/":[],"https://www.aljazeera.com/videos/":[],"https://www.cnn.com/privacy":[],"https://www.cnn.com/terms":[],"https://www.cnn.com/us":[]} |
Oops, something went wrong.