Documentation Index
Fetch the complete documentation index at: https://ship.paralect.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Workflow — is a complex business operation that requires two or more data services to be used together. If a workflow is simple enough and used only in one place — it can be defined right in the endpoint handler. If not — it should be placed into the ‘workflowName.workflow’ file. A most common workflow example is a signup.workflow that exposes createUserAccount function and used when new user signs up or receive an invite.
Examples
import userService from 'resources/user/user.service';
import companyService from 'resources/company/company.service';
const signup = async ({
firstName,
surname,
email,
}: {
firstName: string;
surname: string;
email: string,
}) : Promise<User> => {
let signedUpUser = null;
await companyService.withTransaction(async (session: any) => {
const companyId = companyService.generateId();
await companyService.insertOne({
_id: companyId,
name: '',
},
{ session });
signedUpUser = await userService.insertOne({
_id: userId,
companyId,
email,
firstName,
surname,
},
{ session });
});
return signedUpUser;
};
export default {
signup,
};