22 lines
581 B
JavaScript
22 lines
581 B
JavaScript
module.exports = Self => {
|
|
Self.remoteMethodCtx('add', {
|
|
description: 'Add a new operator',
|
|
accessType: 'WRITE',
|
|
http: {
|
|
path: `/add`,
|
|
verb: 'POST'
|
|
}
|
|
});
|
|
|
|
Self.add = async(ctx, options) => {
|
|
const userId = ctx.req.accessToken.userId;
|
|
const myOptions = {};
|
|
|
|
if (typeof options == 'object')
|
|
Object.assign(myOptions, options);
|
|
|
|
const isOperator = await Self.findById(userId, myOptions);
|
|
if (!isOperator) await Self.create({workerFk: userId}, myOptions);
|
|
};
|
|
};
|