could be converted to a swtich-statement? I read that a lot of if else-statements should be avoided if possible. But since those queries only seem to give out booleans, it seems to be tricky at best. But I was wondering if someone has any solution to this?
the problem in your code is that it is not DRY (DRY - don’t repeat yourself)
you could do:
const hasItemSlot = (itemSlot) => Worlds_Items.findOne({_id:FlowRouter.getParam('item'), itemSlot}))
// and then
if(hasItemSlot("head")) return "Head"
if(hasItemSlot("torso")) return "Torso"
etc.
but its a bit weird anyway, because Worlds_Items.findOne({_id:FlowRouter.getParam('item')}) will return the same object in every case. its cleaner if you do
Minimongo doesn’t currently have indexes. It’s rare for this to be an issue, since it’s unusual for a client to have enough data that an index is worthwhile.