-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
71 lines (57 loc) · 1.91 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const connectDB = require("./Database/connect");
connectDB();
var Projects = require("./Database/model/Projects");
var Posts = require("./Database/model/Posts");
var Users = require("./Database/model/Users");
(async function(){try{
var ulist = await Users.find({ });
for (var u of ulist) {
// Check if the user has a default avatar and banner
if (u.avatar == "https://fakeimg.pl/300x300") u.avatar = "https://watermelonkatana.com/images/default_pfp.png";
if (u.banner == "https://fakeimg.pl/720x360") u.banner = "https://watermelonkatana.com/images/default_banner.png";
//u.avatar = "https://fakeimg.pl/300x300";
//u.banner = "https://fakeimg.pl/720x360";
//u.biography = "This user has not added a biography yet.";
//u.joinedAt = Date.now();
//u.mature = false;
console.log(u);
await u.save();
}
//Projects.updateMany({ },{views:0,thumbnail:""}).then(console.log);
//* Run when converting to ref
var list = await Projects.find({ });
for (var p of list) {
//var u = await Users.findById(p[i].posterId);
//p[i].poster = u;
//delete p[i].posterId;
delete p.iscdo;
delete p.iskhan;
delete p.isscratch;
if (!p.activeAt) p.activeAt = p.postedAt;
p.mature = false;
p.hidden = false;
p.privateRecipients = [];
p.title = p.name;
delete p.name;
p.content = p.desc;
delete p.desc;
console.log(p);
await p.save();
}
var list = await Posts.find({ });
for (var p of list) {
//var u = await Users.findById(p[i].posterId);
//p[i].poster = u;
//delete p[i].posterId;
if (!p.activeAt) p.activeAt = p.postedAt;
p.mature = false;
p.hidden = false;
p.privateRecipients = [];
p.title = p.name;
delete p.name;
console.log(p);
await p.save();
}
//*/
// Update all users who have a default avatar and banner to the new placeholders
console.log("Done!")}catch(e){console.log(e);}})();