Added script to migrate tweets

This commit is contained in:
TheEssem 2020-07-26 19:58:19 -05:00
parent 6eee7c6058
commit 7a13431dfa
2 changed files with 23 additions and 1 deletions

1
.gitignore vendored
View file

@ -39,5 +39,4 @@ todo.txt
tweets.json
.vscode/
migratedb.js
migratetweets.js
processed.txt

23
migratetweets.js Normal file
View file

@ -0,0 +1,23 @@
const fs = require("fs");
const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost/esmBot");
const tweetSchema = new mongoose.Schema({
tweets: [String],
replies: [String],
media: [String],
phrases: [String],
games: [String],
characters: [String],
download: [String],
enabled: Boolean
});
const TweetCollection = mongoose.model("TweetCollection", tweetSchema);
TweetCollection.findOne({}, (err, res) => {
if (err) throw err;
fs.writeFileSync("tweets.json", JSON.stringify(res));
console.log("Migrated!");
mongoose.connection.close();
});