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

Database functions #37

Open
loganmhb opened this issue Nov 7, 2018 · 0 comments
Open

Database functions #37

loganmhb opened this issue Nov 7, 2018 · 0 comments

Comments

@loganmhb
Copy link
Owner

loganmhb commented Nov 7, 2018

Since queries are executed client-side, it's possible but not idea to squeak by without user-defined database functions. Transactions are not, though, and for expressive transactions user-defined database functions are a hard requirement. The simplest way to do this is probably to support Lua or some similar scripting language in the transactor, and possibly in the query language as well.

Datomic requires functions to be installed on the transactor ahead of time, which is one option. Another would be to define a special function attribute db:fn, analogous to db:ident et al, which would allow an entity to act as a function:

-- Define the function
{db:ident string:palindrome db:fn "function palindrome(s) return s == string.reverse(s) end"}
-- Use the function in a query
find ?e where ?e person:name ?name, string:palindrome(?name)

There might need to be different types for query functions (used as predicates or to generate data) vs transaction functions (which can make arbitrary mutations to the database).

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

No branches or pull requests

1 participant