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?