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: Procedures or Functions #247
Comments
|
If this feature gets added, it would be nice to be able to call a procedure in an event. |
|
+1 for this. I currently created a kinda hacky table structure with a table that drops all info and some events that allow me to reuse certain queries but this would make it miles easier |
|
Would like to comment on this: I don't think it would make sense to have a CALL statement to execute the procedures, as this will force you to use subqueries to invoke them, eventually exhausting the limits faster. I'd personally say that prefixing them like this: Per your example: |
|
This is the one major feature I was waiting to be added before giving SurrealDB a try. You are a wizard @tobiemh, thanks! |
Is your feature request related to a problem?
I have different use cases for this. Basicly make a callable list of surrealQL instructions with arguments etc.
This would allow us to reduce our API-Size to a minimum.
Describe the solution
My proposal contains a few extensions to statements
Define a procedure to get a person
DEFINE PROCEDURE get_person ($firstname, $lastname, $birthdate) { LET $person = SELECT * FROM person WHERE firstname = $firstname AND lastname = $lastname AND birthdate = $birthdate; IF (COUNT($person)==1) THEN RETURN 1; ELSE RETURN CREATE person { firstname: $firstname, lastname: $lastname, birthdate: $birthdate } END }and call it by
Alternative methods
The specifc syntax doesn't matter the above is only an example that I thought about.
There are some things things to look at:
(#225 might be silightly releated)
SurrealDB version
surreal 1.0.0-beta.7 for windows on x86_64
Contact Details
No response
Is there an existing issue for this?
Code of Conduct
The text was updated successfully, but these errors were encountered: