salix/back/methods/starred-module/getStarredModules.js

29 lines
720 B
JavaScript
Raw Normal View History

module.exports = function(Self) {
Self.remoteMethodCtx('getStarredModules', {
description: 'returns the starred modules for the current user',
2021-03-02 09:33:35 +00:00
accessType: 'READ',
returns: {
type: 'object',
root: true
},
http: {
path: `/getStarredModules`,
verb: 'get'
}
});
Self.getStarredModules = async ctx => {
const userId = ctx.req.accessToken.userId;
const filter = {
where: {
workerFk: userId
},
fields: ['moduleFk']
};
const starredModules = await Self.app.models.StarredModule.find(filter);
return starredModules;
};
};