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

stored procedures? #276

Open
ear7h opened this issue Aug 9, 2024 · 3 comments
Open

stored procedures? #276

ear7h opened this issue Aug 9, 2024 · 3 comments

Comments

@ear7h
Copy link

ear7h commented Aug 9, 2024

Hi, again! I'm messing around with cozo again and came up with an interesting problem. I've created a web of named queries like:

allowed_users[principal, email] := ...

allowed_channels[principal, channel_id] :=
    *channel{author, ...},
    allowed_users[principal, author], ...

allowed_threads[principal, channel_id, thread_id] :=
    *threads{channel_id, thread_id, author, ...},
    allowed_users[principal, author],
    allowed_channels[principal, channel_id], ...

I'd like to use these as part of implementing GET /users, GET /channels, GET /threads, etc. That is, these queries will just be filters for a queries against *user, *channel, and *thread. As far as I can tell, I'll just have to duplicate this text for each query. But, is there a way to save these queries like function/stored procedure?

@ear7h
Copy link
Author

ear7h commented Aug 9, 2024

Something that has the shape of what I want is fixed rules, and the registration mechanism. However, fixed rules must be implemented in complete isolation to the Db.

@creatorrr
Copy link
Contributor

Currently, we also just duplicate this kind of stuff so stored named rules could be really useful for sure

@docteurklein
Copy link

I think what you're referring to is more like views, not procedures.

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

No branches or pull requests

3 participants