2021-02-26 08:08:31 +00:00
|
|
|
module.exports = function(Self) {
|
|
|
|
Self.remoteMethodCtx('getStarredModules', {
|
2021-03-01 21:21:04 +00:00
|
|
|
description: 'returns the starred modules for the current user',
|
2021-03-02 09:33:35 +00:00
|
|
|
accessType: 'READ',
|
2021-02-26 08:08:31 +00:00
|
|
|
returns: {
|
|
|
|
type: 'object',
|
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
|
|
|
path: `/getStarredModules`,
|
|
|
|
verb: 'get'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-06-01 20:18:13 +00:00
|
|
|
Self.getStarredModules = async(ctx, options) => {
|
|
|
|
const models = Self.app.models;
|
2021-03-01 11:15:13 +00:00
|
|
|
const userId = ctx.req.accessToken.userId;
|
2021-06-01 20:18:13 +00:00
|
|
|
|
|
|
|
let myOptions = {};
|
|
|
|
|
|
|
|
if (typeof options == 'object')
|
|
|
|
Object.assign(myOptions, options);
|
|
|
|
|
2021-03-01 11:15:13 +00:00
|
|
|
const filter = {
|
|
|
|
where: {
|
|
|
|
workerFk: userId
|
|
|
|
},
|
2021-06-01 20:18:13 +00:00
|
|
|
fields: ['id', 'workerFk', 'moduleFk', 'position'],
|
|
|
|
order: 'position ASC'
|
2021-03-01 11:15:13 +00:00
|
|
|
};
|
|
|
|
|
2021-06-01 20:18:13 +00:00
|
|
|
return models.StarredModule.find(filter, myOptions);
|
2021-02-26 08:08:31 +00:00
|
|
|
};
|
|
|
|
};
|