Replies: 3 comments 2 replies
-
Instead of embedded modules and endpoints, I suggest stored procedure/functions with public or private modifiers. Public procedures/functions can also have access permission. We can define a function with Define Function
We should be able to execute these procedures with Execute statement
Surrealdb admin GUI should also has a built-in code editor for writing these functions. |
Beta Was this translation helpful? Give feedback.
-
SurrealDB is already using quickjs so can we can use javascript for writing these procedures. I was in favor of embedded endpoints previously https://discord.com/channels/902568124350599239/902568124350599242/977836523863019530 but now I think there are few advantages of using stored procedures. SQL developers are already familiar with stored procedures, embedded endpoints in a database is a new concept for them (only Arangodb allows writing endpoints with javascript) and we can define and execute stored procedures with SQL statements. No need to expose HTTP endpoints and access these URLs from client. Here is stored procedures purposed syntax
|
Beta Was this translation helpful? Give feedback.
-
What would be the purpose of |
Beta Was this translation helpful? Give feedback.
-
Extending the embedded JavaScript runtime with in-built and custom modules will allow SurrealDB users to implement advanced logic and functionality within SurrealDB. This could include custom logic, implementing specific business logic, making payments, and calling external APIs.
In-built modules
The most important built-in module is one that allows the user to query the current database instance, using the current scope and authentication. This would be similar to how the
surrealdb.js
library works, without the connection functionality, and without the ability to switch namespace / database, or change authentication levels.SurrealDB SQL functions could be made available within JavaScript too.
Another module which should be built-in as a global is the
fetch
command;Third-party modules
Local modules
Local modules could be imported directly with an ES6 import declaration. We would need to decide how local modules are defined (using a custom
DEFINE
statement with the JavaScript / TypeScript code).Remote modules
Remote modules could be imported directly with an ES6 import declaration. Remote modules would need to be cached, and if we support TypeScript then we would need to convert this to JavaScript on the fly, and cache the result.
Beta Was this translation helpful? Give feedback.
All reactions