#Fetching data from a database, filtering it by only guilds handled by the shard

8 messages · Page 1 of 1 (latest)

exotic mason
#

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?

mint topaz
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

exotic mason
#

yes, i know about it

rapid ravineBOT
exotic mason
#

but i'm asking, where do i best use it?

warped shell
#

Anything else not related to discord.js