🐛 fix bigint id in message route

This commit is contained in:
Flam3rboy 2021-04-06 18:07:18 +02:00
parent 7089287016
commit fbeb7ce8f8
2 changed files with 5 additions and 1 deletions

BIN
package-lock.json generated

Binary file not shown.

View File

@ -60,7 +60,11 @@ router.get("/", async (req, res) => {
var query: any;
if (after) query = MessageModel.find({ channel_id, id: { $gt: after } });
else if (before) query = MessageModel.find({ channel_id, id: { $lt: before } });
else if (around) query = MessageModel.find({ channel_id, id: { $gt: around - halfLimit, $lt: around + halfLimit } });
else if (around)
query = MessageModel.find({
channel_id,
id: { $gt: (BigInt(around) - BigInt(halfLimit)).toString(), $lt: (BigInt(around) + BigInt(halfLimit)).toString() },
});
else {
query = MessageModel.find({ channel_id }).sort({ id: -1 });
}