question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is the `crud` alias gone in Ability 4?

See original GitHub issue

When manage changed a few releases ago, the changelog noted

To migrate the code, just replace `manage` with `crud` and everything will work as previously.

These had been in https://github.com/stalniy/casl/blob/%40casl/ability%403.4.0/packages/casl-ability/src/ability.js#L6

In 4.0, this seems to be gone. Is that intentional? I didn’t see it in the changelog. Do we just need our own crud alias now?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
stalniycommented, May 25, 2021

AbilityBuilder is recommended because it doesn’t add additional nesting and the final code is easier to read.

resolveAction is just an AbilityOption. If you use typescript or modern IDE it will help you with where to put it.

import { AbilityBuilder } from ...

const { can, build } = new AbilityBuilder(Ability);

// define rules

const resolveAction = ....

build({ resolveAction })
1reaction
stalniycommented, Apr 14, 2020

From updated changelog

alias: no more default aliases are shipped with @casl/ability. So, if you used crud, you need to add it yourself.

Before:

import { AbilityBuilder } from '@casl/ability';

const ability = AbilityBuilder.define((can) => {
  can("crud", "Post");
});

ability.can("crud", "Post"); // true

After:

import { defineAbility, createAliasResolver } from '@casl/ability';

const resolveAction = createAliasResolver({
  crud: ['create', 'read', 'update', 'delete']
});
const ability = defineAbility({ resolveAction }, (can) => {
  can("crud", "Post"); 
});

ability.can("crud", "Post"); // true
Read more comments on GitHub >

github_iconTop Results From Across the Web

Chapter 41: MySQL CRUD Action – The Missing Link
These four actions are collectively referred to as CRUD, for Create Read Update and Delete, and represent the basic concepts behind data interaction....
Read more >
Custom endpoint aliases | Elasticsearch Service Documentation
Custom aliases for your deployment endpoints on Elasticsearch Service allow you to have predictable, human-readable URLs that can be shared easily.
Read more >
CRUD tables need to die.. Most business data is begging for a…
Many web programming projects and features start out with modelling the data in a CRUD (Create, Read, Update, Delete) model.
Read more >
NestJs CRUD for RESTful APIs - @nestjsx/crud - npm
Ability to generate CRUD endpoints with predefined path filter. ... limit (alias per_page ) - receive N amount of entities ...
Read more >
Documentation: 15: INSERT - PostgreSQL
A substitute name for table_name . When an alias is provided, it completely hides the actual name of the table. This is particularly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found