Added script to migrate tweets
This commit is contained in:
		
							parent
							
								
									6eee7c6058
								
							
						
					
					
						commit
						7a13431dfa
					
				
					 2 changed files with 23 additions and 1 deletions
				
			
		
							
								
								
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -39,5 +39,4 @@ todo.txt
 | 
				
			||||||
tweets.json
 | 
					tweets.json
 | 
				
			||||||
.vscode/
 | 
					.vscode/
 | 
				
			||||||
migratedb.js
 | 
					migratedb.js
 | 
				
			||||||
migratetweets.js
 | 
					 | 
				
			||||||
processed.txt
 | 
					processed.txt
 | 
				
			||||||
							
								
								
									
										23
									
								
								migratetweets.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								migratetweets.js
									
										
									
									
									
										Normal 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();
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue