chore: fix various eslint issues #1176
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "eslint-fix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -31,4 +30,2 @@
return ship;
};
export const getShipLean = async (shipOwnerId: string) => {
only because this function is currently not used, does not mean it has to be deleted.
I don't even understand the intended purpose of it. Under which circumstances would you ever want an unhydrated ship combined with the loadout presets?
hydration is ONLY needed when you want to use a mongoose document's functions.
So, all get requests should generally only use .lean() versions, so mongoose doesn't hydrate them (which takes lots of resources)
I left the function there as a reminder to do that
lean
also seems to skip casing and validation, potentially invalidating the types.I am not aware of that.
https://github.com/Automattic/mongoose/blob/master/docs/tutorials/lean.md
it describes getters as a good use case for using lean, which makes sense to me
Literally search for "Casting and validation" on that page.
The ship model also makes use of transformations, so we'd not get a correct client representation if we used
lean
.Right, however I don't think validation or casting is required during retrieval of a document, since that also happens during saving, so it should be impossible to even have invalid objects. Other than when someone would manually change stuff, but accounting for that possibility does not seem reasonable.
Since we use virtuals, and they rely on hydration apparently, we cannot use .lean() indeed.
However, your change was sus to me, because you just removed it while it had a purpose. What we discovered now does not change that removing stuff just like that is not so great
I removed it because it didn't serve any apparent purpose and did not have a return type, hence raising a warning.