trc-role-permission

1.0.1 • Public • Published

Roles

  1. To Create Role
    Function Name: createRoleFunction
    Arguments : Object

    Example:

    let payload = {
        name: "Function Test",
        createdBy: "cs",
    };
    
    const role = await createRoleFunction(payload);

    output:

     {
     "name": 'Function Test',
     "id": '4ed05209-710b-4a8d-bdc9-1eae6949245c',
     "createdBy": 'cs',
     "status": true,
     "_id": new ObjectId('65bb22adf2f9e5cb3efa2029'),
     "createdAt": 2024-02-01T04: 48: 45.945Z,
     "updatedAt": 2024-02-01T04: 48: 45.945Z,
     "__v": 0
    }

  1. Get Role By Id
    Function Name: getRoleByIdFunction
    Arguments : roleId

    Example:

    let roleId = "4ed05209-710b-4a8d-bdc9-1eae6949245c"
    const role = await getRoleByIdFunction(roleId);

    output:

     {
     "name": 'Function Test',
     "id": '4ed05209-710b-4a8d-bdc9-1eae6949245c',
     "createdBy": 'cs',
     "status": true,
     "_id": new ObjectId('65bb22adf2f9e5cb3efa2029'),
     "createdAt": 2024-02-01T04: 48: 45.945Z,
     "updatedAt": 2024-02-01T04: 48: 45.945Z,
     "__v": 0
    }

  1. Update Role By Id
    Function Name: updateRoleByIdFunction
    Arguments : roleId,Object

    Example:

    let roleId = "4ed05209-710b-4a8d-bdc9-1eae6949245c"
    let payload = {
      name: "update role"
    }
    
    const role = await getRoleByIdFunction(roleId,payload);

    output:

     {
     "name": 'update role',
     "id": '4ed05209-710b-4a8d-bdc9-1eae6949245c',
     "createdBy": 'cs',
     "status": true,
     "_id": new ObjectId('65bb22adf2f9e5cb3efa2029'),
     "createdAt": 2024-02-01T04: 48: 45.945Z,
     "updatedAt": 2024-02-01T04: 48: 45.945Z,
     "__v": 0
    }

  1. Delete Role By Id
    Function Name: deleteRoleByIdFunction
    Arguments : roleId

    Example:

    let roleId = "4ed05209-710b-4a8d-bdc9-1eae6949245c"
    
    const role = await deleteRoleByIdFunction(roleId);

    output:

     {
     "name": 'deleted role',
     "id": '4ed05209-710b-4a8d-bdc9-1eae6949245c',
     "createdBy": 'cs',
     "status": true,
     "_id": new ObjectId('65bb22adf2f9e5cb3efa2029'),
     "createdAt": 2024-02-01T04: 48: 45.945Z,
     "updatedAt": 2024-02-01T04: 48: 45.945Z,
     "__v": 0
    }

Permissions

  1. To Create Permissions
    Function Name: createPermissionFunction
    Arguments : Object

    Example:

    let payload = {
        name: "Permission Name"
    };
    
    const permission = await createPermissionFunction(payload);

    output:

     {
     "name": 'Permission Name',
     "id": '5e210a60-bfaa-4a89-af1b-789b975b61cd',
     "status": true,
     "_id": new ObjectId('65bb2f91954dc5eb4bb641c6'),
     "createdAt": 2024-02-01T05:43:45.079Z,
     "updatedAt": 2024-02-01T05:43:45.079Z,
     "__v": 0
    }

  1. To Update Permissions
    Function Name: updatePermissionFunction
    Arguments : Object

    Example:

    let permissionId = "5e210a60-bfaa-4a89-af1b-789b975b61cd"
    let payload = {
        name: "Permission Name"
    };
    
    let permission = await updatePermissionFunction(permissionId,payload);

    output:

     {
     "name": 'Permission Name',
     "id": '5e210a60-bfaa-4a89-af1b-789b975b61cd',
     "status": true,
     "_id": new ObjectId('65bb2f91954dc5eb4bb641c6'),
     "createdAt": 2024-02-01T05:43:45.079Z,
     "updatedAt": 2024-02-01T05:43:45.079Z,
     "__v": 0
    }

  1. To Delete Permissions
    Function Name: deletePermissionFunction
    Arguments : Object

    Example:

    let permissionId = "5e210a60-bfaa-4a89-af1b-789b975b61cd"
    
    let permission = await deletePermissionFunction(permissionId);

    output:

     {
     "name": 'Deleted',
     "id": '5e210a60-bfaa-4a89-af1b-789b975b61cd',
     "status": true,
     "_id": new ObjectId('65bb2f91954dc5eb4bb641c6'),
     "createdAt": 2024-02-01T05:43:45.079Z,
     "updatedAt": 2024-02-01T05:43:45.079Z,
     "__v": 0
    }

ModuleToPermission

  1. Function To Create Permission Modules
    Function Name: createPermissionToModuleFunction
    Arguments : Object

    Example:

    let payload = {
      moduleId: "123",
      moduleName: "testModule",
      permissions: [
        {
          name: "test1",
          permissionId: "123",
          assignedBy: "vj",
        },
      ],
    };
    
    const permissionToModule = await createPermissionToModuleFunction(payload);

    output:

     {
      "id": '795233b2-a8a0-449b-beb9-c3d64e21482d',
      "moduleName": "test1",
      "moduleId": "1234",
      "permissions": [
         {
             "name": "test2",
             "permissionId": 11,
             "assignedBy": "vj"
         }
     ],
     "status": true,
     "_id": new ObjectId("65ba1b2f2fab145140390803"),
     "createdAt": 2024-01-31T10: 04: 31.088Z,
     "updatedAt": 2024-01-31T10: 04: 31.088Z,
     "__v": 0
    }

  1. Function To Create New permissions
    Function Name: addPermissionsToModuleFunction
    Arguments : moduleId,ArrayOfObject

    Example:

    let payload = [
      {
        name: "test",
        permissionId: "123",
        assignedBy: "vj",
      },
    ];
    let moduleId = "1234;";
    
    const permissions = await addPermissionsToModuleFunction(moduleId, payload);

    output:

     {
      "id": '795233b2-a8a0-449b-beb9-c3d64e21482d',
      "moduleName": "Vj",
      "moduleId": "1234",
      "permissions": [
         {
             "name": "test1",
             "permissionId": 11,
             "assignedBy": "vj"
         },
         {
             "name": "test2",
             "permissionId": 12,
             "assignedBy": "vj"
         }
    
     ],
     "status": true,
     "_id": new ObjectId("65ba1b2f2fab145140390803"),
     "createdAt": 2024-01-31T10: 04: 31.088Z,
     "updatedAt": 2024-01-31T10: 04: 31.088Z,
     "__v": 0
    }

  1. Function remove permissions
    Function Name: removePermissionToModuleFunction
    Arguments : moduleId,permissionId

    Example:

    let moduleId = "1234";
    let permissionId = "12";
    
    const permissions = await addPermissionsToModuleFunction(moduleId, permissionId);

    output:

     {
      "id": '795233b2-a8a0-449b-beb9-c3d64e21482d',
      "moduleName": "Vj",
      "moduleId": "1234",
      "permissions": [
         {
             "name": "test1",
             "permissionId": 11,
             "assignedBy": "vj"
         }
    
     ],
     "status": true,
     "_id": new ObjectId("65ba1b2f2fab145140390803"),
     "createdAt": 2024-01-31T10: 04: 31.088Z,
     "updatedAt": 2024-01-31T10: 04: 31.088Z,
     "__v": 0
    }

  1. Function update permissions
    Function Name: updatePermissionToModuleFunction
    Arguments : moduleId,permissionId

    Example:

    let moduleId = "1234";
    const modifiedPermission = {
      name: "test121",
      permissionId: "123",
      assignedBy: "user123",
    };
    
    const permissions = await addPermissionsToModuleFunction(moduleId, modifiedPermission);

    output:

     {
      "id": '795233b2-a8a0-449b-beb9-c3d64e21482d',
      "moduleName": "Vj",
      "moduleId": "1234",
      "permissions": [
         {
             "name": "test121",
             "permissionId": "123",
             "assignedBy": "user123"
         }
    
     ],
     "status": true,
     "_id": new ObjectId("65ba1b2f2fab145140390803"),
     "createdAt": 2024-01-31T10: 04: 31.088Z,
     "updatedAt": 2024-01-31T10: 04: 31.088Z,
     "__v": 0
    }

Readme

Keywords

none

Package Sidebar

Install

npm i trc-role-permission

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

35.9 kB

Total Files

21

Last publish

Collaborators

  • chandrakant-shinde