Skip to content

Conversation

FreePhoenix888
Copy link
Member

@FreePhoenix888 FreePhoenix888 commented Feb 9, 2024

Resolves #301

@FreePhoenix888 FreePhoenix888 added the documentation Improvements or additions to documentation label Feb 9, 2024
@FreePhoenix888 FreePhoenix888 self-assigned this Feb 9, 2024
@FreePhoenix888 FreePhoenix888 marked this pull request as draft February 9, 2024 09:56
@FreePhoenix888
Copy link
Member Author

What documentation would you add to can?

deeplinks/imports/client.tsx

Lines 1515 to 1531 in dcdee14

/**
* Checks whether {@link subjectUds} can perform {@link actionIds} on {@link objectIds}
* @param objectIds A link id or an array of link ids to check whether the {@link subjectUds} can perform the {@link actionIds} on
* @param subjectIds A link id or an array of link ids to check whether they can perform the {@link actionIds} on the {@link objectIds}
* @param actionIds A link id or an array of link ids to check whether the {@link subjectUds} can perform on the {@link objectIds}
* @param userIds A link id or an array of link ids from which perspective the check is performed
* @returns A promise that resolves to a boolean value indicating whether the {@link subjectUds} can perform the {@link actionIds} on the {@link objectIds}
*/
async can(objectIds: null | number | number[], subjectIds: null | number | number[], actionIds: null | number | number[], userIds: number | number[] = this.linkId) {
const where: any = {
};
if (objectIds) where.object_id = typeof(objectIds) === 'number' ? { _eq: +objectIds } : { _in: objectIds };
if (subjectIds) where.subject_id = typeof(subjectIds) === 'number' ? { _eq: +subjectIds } : { _in: subjectIds };
if (actionIds) where.action_id = typeof(actionIds) === 'number' ? { _eq: +actionIds } : { _in: actionIds };
const result = await this.select(where, { table: 'can', returning: 'rule_id' });
return !!result?.data?.length;
}

@konard

@FreePhoenix888 FreePhoenix888 marked this pull request as ready for review February 15, 2024 08:10
@FreePhoenix888 FreePhoenix888 mentioned this pull request Feb 15, 2024
2 tasks
@FreePhoenix888 FreePhoenix888 merged commit b6e6c18 into main Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add in-code documentation

1 participant