7152-devToTest_2414 #2228

Merged
alexm merged 636 commits from 7152-devToTest_2414 into test 2024-03-28 08:26:34 +00:00
3 changed files with 24 additions and 1 deletions
Showing only changes of commit d0975f0acd - Show all commits

View File

View File

@ -0,0 +1,21 @@
module.exports = Self => {
Self.remoteMethodCtx('add', {
description: 'Add a new operator',
accessType: 'WRITE',
http: {
path: `/add`,
verb: 'POST'
}
});
Self.add = async ctx => {
const userId = ctx.req.accessToken.userId;
// He visto findOrCreate pero no funciona
const user = await Self.findById(userId);
if (!user) {
await Self.create({
workerFk: userId
});
}
};
};

View File

@ -1,4 +1,6 @@
module.exports = function(Self) {
module.exports = Self => {
require('../methods/operator/add')(Self);
Self.observe('after save', async function(ctx) {
const instance = ctx.data || ctx.instance;
const models = Self.app.models;