Help is on the way! To mark it as solved, use the /solve command. In the meantime, here are some existing threads that may help you:
#How to extend the payload object with custom methods?
1 messages · Page 1 of 1 (latest)
What are you trying to do? Why not just functional programming?
I'm trying to extend the payload object with custom methods such as findOne (that wraps the default find method) and be able to retrieve it both from req.payload and from the payload object I get with import payload from 'payload', so then I can do req.payload.findOne({}) and payload.findOne({})
Yeah, a popular piece of advice when programming in general is to not extend an object you don't own.
If I were you, I'd do findOne(payload, {}) or findOne(req.payload, {}).
On the other hand, if the collection is obtained by id, remember that you have payload.findById. Finally, if the method has a good reason for being, you can justify it as a feature request and we can consider adding it.