I gather that Parse Server cloud functions don’t support wildcard className? At least I can’t find in the docs.
Parse.Cloud.beforeSave("Review", (request) => { ... })
In my application I have dozens, eventually hundreds of classes. Most of these require some business logic on save. (eg search indexing key fields, checking object relationships, etc)
Currently it seems I have to manually define lists of classes to map classes to callbacks. This is terrible frustrating, slow and fragile/hard to maintain as the application grows.
//- config.js
const classes = [ 'A', 'B', 'C' ]
//- callback.js
config.classes()
.forEach(className => {
initialize(className)
})
function initialize (className) {
Parse.Cloud.beforeSave(className, async (request) => {
//- do something useful...
})
}
I would much prefer to use business logic to dynamically/programmatically decide if a save function needs to be called … eg:
Parse.Cloud.beforeSave("*", (request) => {
if (!someNecessaryCondition) return
//- do some application logic
})
This way, I have much simpler and robust way to determine whether a call back applies. In my case, so far, have to map 18 classes to 8 different callbacks and it’s already becoming hard to maintain … and we haven’t launched yet
Thoughts?