Coder Social home page Coder Social logo

Comments (4)

stalniy avatar stalniy commented on June 16, 2024

Casl wraps everything in OR because in case of multiple rules for the same action/subject type they are OR-ed.

I can optimize it for single OR condition but then your whole app may be broken because at some point in the future you may add additional condition.

So Iā€™d not rely on the shape of the conditions casl returns you back

from casl.

13uraksahin avatar 13uraksahin commented on June 16, 2024

Hmm, I got the point. Correct as fundamental.

However, without any extra or (or anything else), we can also add our own AND or OR conditions, and with the proper documentation, this can be understood and used by developers much more easily. Should it really be OR-ed by default while I can write myself? Because we have the @casl/prisma package, but we cannot use with the prisma if we won't use findMany or findFirst, (I mean we really cannot use with prisma). Also, I am not sure, but this can be done with casl because doc only shows how to write findMany and this update won't affect findMany.

What I suggest makes us to be able to:
We can add all types of conditions to the conditions inside can/cannot which will create accessibleBy(ability)
We can add all types of conditions to the prisma where object
We can combine both of above
Won't violate the fundamentals
Won't break the apps written with documentation

I think this is easier while brings much more possibilities to the code. And I think it does not violates the fundamentals. We still create.

from casl.

saboorajat avatar saboorajat commented on June 16, 2024

Hey,
I want to have condition which will check that if last_name is present then it must be Tony but as it's update API we might not send last_name hence the other condition. It would have been nice if $or was available for use. Also, i noticed if i want to have multiple conditions example first_name then ability.relevantRuleFor(inputAction as ACTIONS, subject(String(subjectName), { [key]: value })
will be true always

{
            type: "can",
            action: ACTIONS.UPDATE_INPUT,
            subject,
            fields: ["first_name", "last_name", "id", "email"],
            condition: { last_name: "Tony" },
        },
        {
            type: "can",
            action: ACTIONS.UPDATE_INPUT,
            subject,
            fields: ["first_name", "last_name", "id", "email"],
            condition: { last_name: { $exists: false } },
        },

from casl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.