chiselstrike
chiselstrike copied to clipboard
Sharding/Partitioning: How to?
In my application each user interacting with his own encrypted data synced across his devices, and therefore I need to have a new sqlite instance spin up for every user.. assume there are only a couple of users.. what's the easiest way to do it..
Considered alternatives:
-
add user_id field to each model and filter by authenticated request..
-
run multiple chisel processes on different ports
-
single chisel process dynamically choosing underlying database file by endpoint.. there is usually /dev endpoint in the URL..
If you absolutely require separate databases, then 2. is your only option right now. But if you trust ChiselStrike to keep the users out of each other's data, consider using the match_login
policy.
Another option.. partitioned tables.. can I create multiple CRUD endpoints using the same table model but unique rows?
match_login seems a good option.. but also I need to implement "sharing" feature.. how can I modify it's transformer to NOT ignore those rows which has been made public by it's author?
match_login seems a good option.. but also I need to implement "sharing" feature.. how can I modify it's transformer to NOT ignore those rows which has been made public by it's author?
We are evolving the policy language in that direction, stay tuned. :)
Another option.. partitioned tables.. can I create multiple CRUD endpoints using the same table model but unique rows?
Yes, but you'll also need custom code to implement the sharing usecase.
@7flash The policy overhaul being done by @MarinPostma is happening in PRs like this: https://github.com/chiselstrike/chiselstrike/pull/1746
The main idea is that it will be native typescript instead of YAML, and then you will be able to express your custom logic. One use case we have in mind is to do both access control and geo-location (if users are in Europe, store data in a database that stays in Europe). I guess your use case is a variation of the latter, so it would work well.
Feedback on that work is appreciated!
hello @7flash, the work on typescript policy is still very WIP, but happy to discuss your usecase!