Advertisement
elliottchong

copy workflowfields from one workflow to another

Feb 23rd, 2024
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import { db } from "@cascading/db/prisma";
  2.  
  3. const workflowFields = await db.workflowFields.findMany({
  4. where: {
  5. // this is the ID of the workflow schema that you want to copy from
  6. workflowSchemaId: 'clr711oof0056tnh91cxxcevs'
  7. }
  8. })
  9. await Promise.all(workflowFields.map(async (workflowField) => {
  10. return await db.workflowFields.create({
  11. data: {
  12. dataType: workflowField.dataType,
  13. name: workflowField.name,
  14. order: workflowField.order,
  15. codeName: workflowField.codeName,
  16. defaultValue: workflowField.defaultValue,
  17. description: workflowField.description,
  18. isInput: workflowField.isInput,
  19. options: workflowField.options,
  20. required: workflowField.required,
  21. validation: workflowField.validation,
  22. // this is the ID of the workflow schema that you want to copy to
  23. workflowSchemaId: 'clszn5h57001mn0xy36wbcxys'
  24. }
  25. })
  26. }))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement