MenuDocs / Pyro

A Python Discord Bot
Apache License 2.0
26 stars 6 forks source link

Cleaned mongo wrapper code #28

Closed ribosomerocker closed 4 years ago

Skelmis commented 4 years ago

Theres more in this file that needs changing. Might as well do it now

Skelmis commented 4 years ago
Skelmis commented 4 years ago

This relates to Episode 21 code, however it is in the Pyro mongo code. Given our upsert method does not check whether or not the item exists, it simply calls update_by_id this causes issues on guilds that don't exist because in update_by_id we return if the item does not exist. See where this is going....

Your choice how it is resolved. But it does need to be resolved or any data currently upserted in new guilds is not being stored

ribosomerocker commented 4 years ago
  • [ ] find_by_id needs to explicitly check if the data is none rather then using not
  • [ ] find_by_custom, see above
  • [ ] delete_by_id, no need for the if. Simply call the method and if it errors it errors
  • [ ] insert, while we are at it. Let's change away from built-in types, so rename dict to data or something
  • [ ] upsert, see above
  • [ ] update_by_id, see above
  • [ ] update_by_id, no need for the if
  • [ ] unset, see both of the ones for update_by_id
  • [ ] increment, no need for the if

I don't see the need for being more explicit here, there doesn't seem to be some sort of value in a string that would mess this up other than, well... the string having no value. Using the is None treatment could be harder to make sense of in a quick look as well, and is more verbose.