1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-11 05:02:37 +01:00

.lean() all mongodb requests

This commit is contained in:
Flam3rboy 2021-04-06 04:05:18 +02:00
parent 0e9089dee9
commit d774216bc8
7 changed files with 12 additions and 8 deletions

View File

@ -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);
});

View File

@ -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);

View File

@ -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);
});

View File

@ -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);
});

View File

@ -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);

View File

@ -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,

View File

@ -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);
});