salix/back/methods/user-config-view/getConfig.js

33 lines
895 B
JavaScript

module.exports = function(Self) {
Self.remoteMethodCtx('getConfig', {
description: 'returns the information from UserConfig model for the active user',
accepts: [
{
arg: 'ctx',
type: 'Object',
http: {source: 'context'}
}, {
arg: 'tableCode',
type: 'String',
description: `Code of the table you ask its configuration`
}
],
returns: {
type: 'object',
root: true
},
http: {
path: `/getConfig`,
verb: 'get'
}
});
Self.getConfig = async ctx => {
let userView = await Self.app.models.UserConfigView.findOne({
where: {tableCode: ctx.args.tableCode, userFk: ctx.req.accessToken.userId}
});
return userView;
};
};