Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] create if not exist for Update APIs #194

Closed
nonchan7720 opened this issue Jan 14, 2023 · 6 comments
Closed

[feature] create if not exist for Update APIs #194

nonchan7720 opened this issue Jan 14, 2023 · 6 comments

Comments

@nonchan7720
Copy link
Contributor

Want to prioritize this issue? Try:

issuehunt-to-marktext


What's your scenario? What do you want to achieve?
Do you plan to offer a feature like Upsert?

UpdateXXX and UpdateFilteredXXX assume that existing policies and rules exist.
We are willing to create the features we are requesting if they do not exist and update them if they do.
I would also like to see this same feature in Grouping.

The reason I need this is that I am trying to use RDB for storing policies, and I want to achieve this within the same transaction.
Adapter to be used

@casbin-bot
Copy link
Member

@tangyang9464 @JalinWang

@hsluoyz hsluoyz transferred this issue from casbin/casbin Jan 14, 2023
@casbin-bot
Copy link
Member

@hsluoyz hsluoyz changed the title [Question] [feature] create if not exist for Update APIs Jan 14, 2023
@nonchan7720
Copy link
Contributor Author

Sorry.
I made a mistake in the content.

What I meant to say is that I would like to see a feature like Replace.

As an example of use, we would like to filter Policy and Grouping to perform a search, delete existing rules if they exist, and create new rules as given.

@hsluoyz
Copy link
Member

hsluoyz commented Jan 16, 2023

@nonchan7720 what you said is how Update APIs work now? If exist, then update. If not exist, then error (and not update). Isn't this what you want?

@nonchan7720
Copy link
Contributor Author

nonchan7720 commented Jan 16, 2023

@hsluoyz
My hope is that existing rules will be created and propagated to watchers and others even if they do not exist.

Expect line 445 to be skipped.
https://github.com/casbin/casbin/blob/540b521da0f969ed8f1b348c6fb34edc0e668a86/internal_api.go#L443-L447

@hsluoyz
Copy link
Member

hsluoyz commented Feb 5, 2023

@nonchan7720 this requirement is very rare. You can fork the code and use your own fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants