diff --git a/.wappler/targets/Development/databases/MyDB.json b/.wappler/targets/Development/databases/MyDB.json index c27b117..1c37ef1 100644 --- a/.wappler/targets/Development/databases/MyDB.json +++ b/.wappler/targets/Development/databases/MyDB.json @@ -10,6 +10,36 @@ "direct": true, "schema": { "tables": { + "da_metaData": { + "db": {} + }, + "da_meta": { + "columns": { + "id": { + "db": { + "type": "increments", + "primary": true, + "nullable": false + } + }, + "da_id": { + "db": { + "type": "integer", + "primary": false, + "nullable": true + } + }, + "obj_dataStore": { + "db": { + "type": "text", + "maxLength": 65535, + "primary": false, + "nullable": true + } + } + }, + "db": {} + }, "da": { "columns": { "id": { @@ -74,30 +104,6 @@ "primary": false, "nullable": true } - } - }, - "db": { - "engine": "InnoDB", - "schema": "db_training", - "collation": "utf8mb4_unicode_ci", - "system_versioned": false - } - }, - "da_meta": { - "columns": { - "id": { - "db": { - "type": "increments", - "primary": true, - "nullable": false - } - }, - "da_id": { - "db": { - "type": "integer", - "primary": false, - "nullable": true - } }, "obj_dataStore": { "db": { diff --git a/app/api/myInsertMetaUpsert.json b/app/api/myInsertMetaUpsert.json new file mode 100644 index 0000000..35ff090 --- /dev/null +++ b/app/api/myInsertMetaUpsert.json @@ -0,0 +1,51 @@ +{ + "meta": { + "$_GET": [ + { + "type": "number", + "name": "da_id" + }, + { + "type": "object", + "name": "obj_datastore" + }, + { + "type": "number", + "name": "id" + } + ] + }, + "exec": { + "steps": { + "name": "MyUpsert", + "module": "dbupdater", + "action": "custom", + "options": { + "connection": "MyDB", + "sql": { + "query": "INSERT INTO `da_meta` (`id`, `da_id`, `obj_dataStore`) \nVALUES (?, ?, ?) \nON DUPLICATE KEY UPDATE \n`obj_dataStore` = VALUES(`obj_dataStore`), \n`da_id` = VALUES(`da_id`);\n\n", + "params": [ + { + "name": ":P1", + "value": "{{$_GET.id}}", + "recid": 1 + }, + { + "name": ":P2", + "value": "{{$_GET.da_id}}", + "recid": 2 + }, + { + "name": ":P3", + "value": "{{$_GET.obj_datastore}}", + "recid": 3 + } + ] + } + }, + "output": true, + "meta": [], + "outputType": "array" + } + } +} \ No newline at end of file diff --git a/app/api/myRecordUpdateByID.json b/app/api/myRecordUpdateByID.json new file mode 100644 index 0000000..3067ccf --- /dev/null +++ b/app/api/myRecordUpdateByID.json @@ -0,0 +1,74 @@ +{ + "meta": { + "$_POST": [ + { + "type": "text", + "name": "obj_dataStore" + }, + { + "type": "number", + "name": "id" + } + ] + }, + "exec": { + "steps": { + "name": "MyRecordUpdate", + "module": "dbupdater", + "action": "update", + "options": { + "connection": "MyDB", + "sql": { + "type": "update", + "values": [ + { + "table": "da", + "column": "obj_dataStore", + "type": "text", + "value": "{{$_POST.obj_dataStore}}" + } + ], + "table": "da", + "wheres": { + "condition": "AND", + "rules": [ + { + "id": "id", + "type": "double", + "operator": "equal", + "value": "{{$_POST.id}}", + "data": { + "column": "id" + }, + "operation": "=" + } + ] + }, + "returning": "id", + "query": "update `da` set `obj_dataStore` = ? where `id` = ?", + "params": [ + { + "name": ":P1", + "type": "expression", + "value": "{{$_POST.obj_dataStore}}", + "test": "" + }, + { + "operator": "equal", + "type": "expression", + "name": ":P2", + "value": "{{$_POST.id}}", + "test": "" + } + ] + } + }, + "meta": [ + { + "name": "affected", + "type": "number" + } + ] + } + } +} \ No newline at end of file