You can only use the regular service interface on the client. We found that support for user methods (and all the problems that it brings with it, from a well-defined interface to arbitrary names and parameters) is not really needed, because everything in itself can be described as a resource (service).
The benefits (such as security, predictability, and the sending of well-defined real-time events) have so far far outweighed the small changes in thinking needed to conceptualize your application logic.
In your example, you can create a wrapper service that will receive administrator accounts as follows:
class AdminAccounts { find(params) { const accountService = this.app.service('/api/accounts'); return accountService.find({ query: { adminProfile: { $exists: true } } }); } setup(app) { this.app = app; } } app.use('/api/adminAccounts', new AdminAccounts());
Alternatively, you can implement a hook that maps request parameters to larger requests, such as:
app.service('/api/accounts').hooks({ before: { find(hook) { if(hook.params.query.admin) { hook.params.query.adminProfile = { $exists: true }; } } } });
Now it will allow calling something like /api/accounts?admin .
See this FAQ for more information.
Daff
source share