.lean() all mongodb requests
This commit is contained in:
parent
0e9089dee9
commit
d774216bc8
@ -60,7 +60,7 @@ router.get("/", async (req: Request, res: Response) => {
|
|||||||
throw new HTTPError("You aren't authorised to access this endpoint", 401);
|
throw new HTTPError("You aren't authorised to access this endpoint", 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
const invites = await InviteModel.find({ guild_id: guID }).exec();
|
const invites = await InviteModel.find({ guild_id: guID }).lean().exec();
|
||||||
res.status(200).send(invites);
|
res.status(200).send(invites);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ router.get("/", async (req, res) => {
|
|||||||
.populate({ path: "mention_channels", select: { id: true, guild_id: true, type: true, name: true } })
|
.populate({ path: "mention_channels", select: { id: true, guild_id: true, type: true, name: true } })
|
||||||
.populate("mention_roles")
|
.populate("mention_roles")
|
||||||
// .populate({ path: "member", select: PublicMemberProjection })
|
// .populate({ path: "member", select: PublicMemberProjection })
|
||||||
|
.lean()
|
||||||
.exec();
|
.exec();
|
||||||
|
|
||||||
return res.json(messages);
|
return res.json(messages);
|
||||||
|
@ -16,7 +16,7 @@ router.get("/", async (req: Request, res: Response) => {
|
|||||||
const guild = await GuildModel.findOne({ id: guild_id }).exec();
|
const guild = await GuildModel.findOne({ id: guild_id }).exec();
|
||||||
if (!guild) throw new HTTPError("Guild not found", 404);
|
if (!guild) throw new HTTPError("Guild not found", 404);
|
||||||
|
|
||||||
var bans = await BanModel.find({ guild_id: guild_id }).exec();
|
var bans = await BanModel.find({ guild_id: guild_id }).lean().exec();
|
||||||
return res.json(bans);
|
return res.json(bans);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ const router = Router();
|
|||||||
|
|
||||||
router.get("/", async (req, res) => {
|
router.get("/", async (req, res) => {
|
||||||
const guild_id = BigInt(req.params.id);
|
const guild_id = BigInt(req.params.id);
|
||||||
const channels = await ChannelModel.find({ guild_id }).exec();
|
const channels = await ChannelModel.find({ guild_id }).lean().exec();
|
||||||
|
|
||||||
res.json(channels);
|
res.json(channels);
|
||||||
});
|
});
|
||||||
|
@ -32,6 +32,7 @@ router.get("/", async (req: Request, res: Response) => {
|
|||||||
var members = await MemberModel.find({ guild_id, ...query }, PublicMemberProjection)
|
var members = await MemberModel.find({ guild_id, ...query }, PublicMemberProjection)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.populate({ path: "user", select: PublicUserProjection })
|
.populate({ path: "user", select: PublicUserProjection })
|
||||||
|
.lean()
|
||||||
.exec();
|
.exec();
|
||||||
|
|
||||||
return res.json(members);
|
return res.json(members);
|
||||||
|
@ -29,11 +29,11 @@ router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) =
|
|||||||
afk_timeout: 300,
|
afk_timeout: 300,
|
||||||
application_id: undefined,
|
application_id: undefined,
|
||||||
banner: undefined,
|
banner: undefined,
|
||||||
default_message_notifications: undefined,
|
default_message_notifications: 0,
|
||||||
description: undefined,
|
description: undefined,
|
||||||
splash: undefined,
|
splash: undefined,
|
||||||
discovery_splash: undefined,
|
discovery_splash: undefined,
|
||||||
explicit_content_filter: undefined,
|
explicit_content_filter: 0,
|
||||||
features: [],
|
features: [],
|
||||||
id: guild_id,
|
id: guild_id,
|
||||||
large: undefined,
|
large: undefined,
|
||||||
@ -48,11 +48,11 @@ router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) =
|
|||||||
premium_tier: 0,
|
premium_tier: 0,
|
||||||
public_updates_channel_id: undefined,
|
public_updates_channel_id: undefined,
|
||||||
rules_channel_id: undefined,
|
rules_channel_id: undefined,
|
||||||
system_channel_flags: undefined,
|
system_channel_flags: 0,
|
||||||
system_channel_id: undefined,
|
system_channel_id: undefined,
|
||||||
unavailable: false,
|
unavailable: false,
|
||||||
vanity_url_code: undefined,
|
vanity_url_code: undefined,
|
||||||
verification_level: undefined,
|
verification_level: 0,
|
||||||
welcome_screen: [],
|
welcome_screen: [],
|
||||||
widget_channel_id: undefined,
|
widget_channel_id: undefined,
|
||||||
widget_enabled: false,
|
widget_enabled: false,
|
||||||
|
@ -11,7 +11,9 @@ router.get("/", async (req: Request, res: Response) => {
|
|||||||
if (!user) throw new HTTPError("User not found", 404);
|
if (!user) throw new HTTPError("User not found", 404);
|
||||||
|
|
||||||
var guildIDs = user.guilds || [];
|
var guildIDs = user.guilds || [];
|
||||||
var guild = await GuildModel.find({ id: { $in: guildIDs } }).exec();
|
var guild = await GuildModel.find({ id: { $in: guildIDs } })
|
||||||
|
.lean()
|
||||||
|
.exec();
|
||||||
res.json(guild);
|
res.json(guild);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user