-
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
150 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
|
||
/* | ||
* Invokes the SQL CRUD Delete slot with the specified parameters. | ||
* | ||
* Provide [connection-string], [database-type], [database], and [table] to inform the action of | ||
* what database/table you want to execute your SQL towards, and add [and] or [or] arguments | ||
* to filter your records. Notice, you can only use one of [or] or [and], and not both. | ||
*/ | ||
.arguments | ||
database-type | ||
type:enum | ||
mandatory:bool:true | ||
values | ||
.:sqlite | ||
.:mssql | ||
.:mysql | ||
.:pgsql | ||
connection-string | ||
type:string | ||
mandatory:bool:true | ||
database | ||
type:string | ||
mandatory:bool:true | ||
table | ||
type:string | ||
mandatory:bool:true | ||
and | ||
type:key-value | ||
mandatory:bool:false | ||
or | ||
type:key-value | ||
mandatory:bool:false | ||
.icon:cloud_download | ||
|
||
// Sanity checking invocation. | ||
validators.mandatory:x:@.arguments/*/table | ||
validators.enum:x:@.arguments/*/database-type | ||
.:sqlite | ||
.:mssql | ||
.:mysql | ||
.:pgsql | ||
|
||
// Applying defaults. | ||
validators.default:x:@.arguments | ||
connection-string:generic | ||
database-type:sqlite | ||
database:magic | ||
|
||
// Ensuring user provided either [or] or [and] and not both. | ||
if | ||
and | ||
exists:x:@.arguments/*/or/* | ||
exists:x:@.arguments/*/and/* | ||
.lambda | ||
|
||
throw:Provide either [or] or [and] to sql-read action, and not both | ||
public:bool:true | ||
status:500 | ||
|
||
// Connection string to actually use as we connect. | ||
.connection-string | ||
|
||
// Caller supplied an explicit [connection-string] argument. | ||
set-value:x:@.connection-string | ||
strings.concat | ||
.:[ | ||
get-value:x:@.arguments/*/connection-string | ||
.:| | ||
get-value:x:@.arguments/*/database | ||
.:] | ||
|
||
// Connecting to database. | ||
data.connect:x:@.connection-string | ||
database-type:x:@.arguments/*/database-type | ||
|
||
// Adding [or] or [and] arguments. | ||
add:x:@data.connect/*/data.delete/*/where | ||
get-nodes:x:@.arguments/*/or | ||
get-nodes:x:@.arguments/*/and | ||
|
||
// Executing SQL. | ||
data.delete:x:@.arguments/*/sql | ||
database-type:x:@.arguments/*/database-type | ||
table:x:@.arguments/*/table | ||
where | ||
return-nodes:x:@data.delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters