diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-04-06 04:05:18 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-04-06 04:05:18 +0200 |
commit | d774216bc8782484ac7b1c562b63aa9f30510177 (patch) | |
tree | dec4c6eeca227a873098a55a52193e088c600ef4 /src/routes | |
parent | :bug: fix routes user.user_data (diff) | |
download | server-d774216bc8782484ac7b1c562b63aa9f30510177.tar.xz |
.lean() all mongodb requests
Diffstat (limited to 'src/routes')
-rw-r--r-- | src/routes/channels/#channel_id/invites.ts | 2 | ||||
-rw-r--r-- | src/routes/channels/#channel_id/messages/index.ts | 1 | ||||
-rw-r--r-- | src/routes/guilds/#id/bans.ts | 2 | ||||
-rw-r--r-- | src/routes/guilds/#id/channels.ts | 2 | ||||
-rw-r--r-- | src/routes/guilds/#id/members.ts | 1 | ||||
-rw-r--r-- | src/routes/guilds/index.ts | 8 | ||||
-rw-r--r-- | src/routes/users/@me/guilds.ts | 4 |
7 files changed, 12 insertions, 8 deletions
diff --git a/src/routes/channels/#channel_id/invites.ts b/src/routes/channels/#channel_id/invites.ts index 403ef36d..c9910ae2 100644 --- a/src/routes/channels/#channel_id/invites.ts +++ b/src/routes/channels/#channel_id/invites.ts @@ -60,7 +60,7 @@ router.get("/", async (req: Request, res: Response) => { 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); }); diff --git a/src/routes/channels/#channel_id/messages/index.ts b/src/routes/channels/#channel_id/messages/index.ts index 590d7059..13c819b4 100644 --- a/src/routes/channels/#channel_id/messages/index.ts +++ b/src/routes/channels/#channel_id/messages/index.ts @@ -72,6 +72,7 @@ router.get("/", async (req, res) => { .populate({ path: "mention_channels", select: { id: true, guild_id: true, type: true, name: true } }) .populate("mention_roles") // .populate({ path: "member", select: PublicMemberProjection }) + .lean() .exec(); return res.json(messages); diff --git a/src/routes/guilds/#id/bans.ts b/src/routes/guilds/#id/bans.ts index 27abba55..ba062a44 100644 --- a/src/routes/guilds/#id/bans.ts +++ b/src/routes/guilds/#id/bans.ts @@ -16,7 +16,7 @@ router.get("/", async (req: Request, res: Response) => { const guild = await GuildModel.findOne({ id: guild_id }).exec(); 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); }); diff --git a/src/routes/guilds/#id/channels.ts b/src/routes/guilds/#id/channels.ts index 599b32d8..df41ec41 100644 --- a/src/routes/guilds/#id/channels.ts +++ b/src/routes/guilds/#id/channels.ts @@ -7,7 +7,7 @@ const router = Router(); router.get("/", async (req, res) => { 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); }); diff --git a/src/routes/guilds/#id/members.ts b/src/routes/guilds/#id/members.ts index de7ea446..25889e2e 100644 --- a/src/routes/guilds/#id/members.ts +++ b/src/routes/guilds/#id/members.ts @@ -32,6 +32,7 @@ router.get("/", async (req: Request, res: Response) => { var members = await MemberModel.find({ guild_id, ...query }, PublicMemberProjection) .limit(limit) .populate({ path: "user", select: PublicUserProjection }) + .lean() .exec(); return res.json(members); diff --git a/src/routes/guilds/index.ts b/src/routes/guilds/index.ts index d7dce64b..57d7ddc4 100644 --- a/src/routes/guilds/index.ts +++ b/src/routes/guilds/index.ts @@ -29,11 +29,11 @@ router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) = afk_timeout: 300, application_id: undefined, banner: undefined, - default_message_notifications: undefined, + default_message_notifications: 0, description: undefined, splash: undefined, discovery_splash: undefined, - explicit_content_filter: undefined, + explicit_content_filter: 0, features: [], id: guild_id, large: undefined, @@ -48,11 +48,11 @@ router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) = premium_tier: 0, public_updates_channel_id: undefined, rules_channel_id: undefined, - system_channel_flags: undefined, + system_channel_flags: 0, system_channel_id: undefined, unavailable: false, vanity_url_code: undefined, - verification_level: undefined, + verification_level: 0, welcome_screen: [], widget_channel_id: undefined, widget_enabled: false, diff --git a/src/routes/users/@me/guilds.ts b/src/routes/users/@me/guilds.ts index 611e622d..1b87b51d 100644 --- a/src/routes/users/@me/guilds.ts +++ b/src/routes/users/@me/guilds.ts @@ -11,7 +11,9 @@ router.get("/", async (req: Request, res: Response) => { if (!user) throw new HTTPError("User not found", 404); 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); }); |