-
Notifications
You must be signed in to change notification settings - Fork 0
/
schemas.js
149 lines (142 loc) · 4.13 KB
/
schemas.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
module.exports = function SCHEMAS(activeConnection){
const miscDB = require("./schemas/_misc.js")(activeConnection);
const serverDB = require("./schemas/servers.js")(activeConnection);
const userDB = require("./schemas/users.js")(activeConnection);
const channelDB = require("./schemas/channels.js")(activeConnection);
const svMetaDB = require("./schemas/serverMeta.js")(activeConnection);
return {
version: require('./package.json').version,
native: miscDB.global.db,
serverDB,
userDB,
channelDB,
svMetaDB,
localranks: require("./schemas/localranks.js")(activeConnection),
rankings: require("./schemas/rankings.js")(activeConnection),
responses: require("./schemas/responses.js")(activeConnection),
audits: require("./schemas/audits.js")(activeConnection),
miscDB,
buyables: miscDB.buyables,
fanart: miscDB.fanart,
globalDB: miscDB.global,
commends: miscDB.commends,
control: miscDB.control,
marketplace: miscDB.marketplace,
reactRoles: miscDB.reactRoles,
paidroles: miscDB.paidroles,
relationships: miscDB.relationships,
alerts: miscDB.alert,
feed: miscDB.feed,
usercols: miscDB.usercols,
gifts: miscDB.gift,
cosmetics: require("./schemas/cosmetics.js")(activeConnection),
collectibles: require("./schemas/collectibles.js")(activeConnection),
items: require("./schemas/items.js")(activeConnection),
achievements: require("./schemas/achievements.js")(activeConnection).ACHIEVEMENTS,
quests: require("./schemas/achievements.js")(activeConnection).QUESTS,
advLocations: (require("./schemas/adventure.js"))(activeConnection).LOCATIONS,
advJourneys: (require("./schemas/adventure.js"))(activeConnection).JOURNEYS,
mutes: require("./schemas/mutes.js")(activeConnection),
temproles: require("./schemas/temproles.js")(activeConnection),
promocodes: require("./schemas/promocodes.js")(activeConnection),
airlines: require("./schemas/airlines.js")(activeConnection),
users: userDB,
servers: serverDB,
guilds: serverDB,
channels: channelDB,
globals: miscDB.global,
marketbase: async function refreshBases(projection) {
let [bgBase, mdBase, stBase, itBase] = await Promise.all([
this.cosmetics.find({
type: "background" /* tradeable:true */
}, {
type: 1,
rarity: 1,
id: 1,
name: 1,
price: 1,
code: 1,
}).lean().exec(),
this.cosmetics.find({
type: "medal" /* tradeable:true */
}, {
type: 1,
rarity: 1,
id: 1,
name: 1,
price: 1,
icon: 1,
}).lean().exec(),
this.cosmetics.find({
type: "sticker" /* tradeable:true */
}, {
type: 1,
rarity: 1,
id: 1,
name: 1,
price: 1,
}).lean().exec(),
this.items.find({
/* tradeable:true */ }, {
type: 1,
rarity: 1,
id: 1,
name: 1,
price: 1,
icon: 1,
}).lean().exec(),
]);
bgBase = bgBase.map((itm) => ({
name: itm.name,
img: `/build/backdrops/${itm.code}.png`,
id: itm.code,
type: itm.type,
rarity: itm.rarity,
price: itm.price,
_id: itm._id,
}));
mdBase = mdBase.map((itm) => ({
name: itm.name,
img: `/medals/${itm.icon}.png`,
id: itm.icon,
type: itm.type,
rarity: itm.rarity,
price: itm.price,
_id: itm._id,
}));
stBase = stBase.map((itm) => ({
name: itm.name,
img: `/build/stickers/${itm.id}.png`,
id: itm.id,
type: itm.type,
rarity: itm.rarity,
price: itm.price,
_id: itm._id,
}));
itBase = itBase.map((itm) => ({
name: itm.name,
img: itm.type == "boosterpack" ? `/boosters/showcase/${itm.id.replace("_booster", ".png")}` : `/build/items/${itm.icon}.png`,
id: itm.id,
type: itm.type,
rarity: itm.rarity,
price: itm.price,
_id: itm._id,
}));
fullbase = [].concat.apply([], [bgBase, mdBase, stBase, itBase]);
if (projection) {
bgBase = !projection.bgBase ? null : bgBase;
mdBase = !projection.mdBase ? null : mdBase;
stBase = !projection.stBase ? null : stBase;
itBase = !projection.itBase ? null : itBase;
fullbase = !projection.fullbase ? null : fullbase;
}
return {
bgBase,
mdBase,
stBase,
itBase,
fullbase,
};
},
};
}