Fetching data from a database, filtering it by only guilds handled by the shard
I have a database containing data about multiple guilds, and i have to fetch some generic data (not necessarily related to a guild in particular), but I want to restrict the results to the entries that have their guild handled by the current shard.
Database is MongoDB, and I use Mongoose.
Now, I have found a few possible solutions, like:
- Filtering the data after having received it from the DB. This potentially results in a lot of memory waste for entries that are better handler by other shards
- Use $in and pass
client.guilds.cache.map(g=>g.id)
, which seems a bit weird considering a shard can be handling a lot of guilds at once
- Use $where, and use the bitwise shift formula, hoping mongo supports BigInt
Is there an efficient way to make this filter, or something I haven't thought of?8 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
yes, i know about it
but i'm asking, where do i best use it?
Anything else not related to discord.js
so i pretty much have to get all the data, and filter it with this later in the bot?