1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00
planka/server/api/helpers/projects/create-one.js
2022-12-26 21:10:50 +01:00

40 lines
679 B
JavaScript

module.exports = {
inputs: {
values: {
type: 'json',
required: true,
},
user: {
type: 'ref',
required: true,
},
request: {
type: 'ref',
},
},
async fn(inputs) {
const { values } = inputs;
const project = await Project.create({ ...values }).fetch();
const projectManager = await ProjectManager.create({
projectId: project.id,
userId: inputs.user.id,
}).fetch();
sails.sockets.broadcast(
`user:${projectManager.userId}`,
'projectCreate',
{
item: project,
},
inputs.request,
);
return {
project,
projectManager,
};
},
};