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.

Database transactions similar api `addPolicies`, `removePolicies`

See original GitHub issue

Hello, recently I’m having another issue, while creating a new user/role, I would like to assign some default rights for it.

We can definitly call multiple times addPolicy but it cannot guarantee that all the default policies have been added, I’m risking having an invalid user in that case.

So I’m thinking if we could have some wrappers like addPolicies, removePolicies.

addPolicies returns Promise<true> only if all the policies have been added, if one of them fails then it cancels this operation (remove the ones have been added)

removePolicies is similar.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:34 (34 by maintainers)

github_iconTop GitHub Comments

2reactions
nodececommented, Apr 27, 2020

@Sefriol Sounds good, but importing it will complicate Casbin.

1reaction
nodececommented, Apr 26, 2020

In casbin-golang, while calling addPolicies in model:

we call hasPolicy to avoid duplicated policies, if one policy already exist, then we cancel the whole operation.

It looks similar to casbin-rs.

TODO in casbin-golang

we insert first into adapter before model, because sometimes we may have network error, in this case we just return the error and don’t even need to insert into model.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adapters - Casbin
Cassandra Adapter, NoSQL, Casbin, ❌, For Apache Cassandra DB ... rules cannot be automatically saved back to the storage when you add or...
Read more >
Database Transactions - Drupal APIs
This is done in Drupal using database transactions. A transaction is started, database writes are made, and if any errors should arise, ...
Read more >
Using Atomic Transactions to Power an Idempotent API
A data race causing two concurrent HTTP requests to insert the same row. Luckily, in this example we've used an even more powerful...
Read more >
How to replicate database transactions in OData environment?
When you interact with IFS using PL/SQL API, you normally open database transactions. You modify and add new records to different tables, ...
Read more >
Transactions and optimistic concurrency control
Traditional relational databases, like SQL Server, allow you to write the business logic using stored-procedures and/or triggers, send it to the ...
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