Newer
Older
AlgebraicDataflowArchitectureModel / AlgebraicDataflowArchitectureModel / models / DatabaseTest2.model
init {
	db := {
		"accountAndBooks": {
			"url": "jdbc:postgresql://localhost:5432/db",
			"user": "root",
			"password": "pass",
			"tables": {
				"accounts": {
					"0": {
						"name": "tmp"
					}
				},
				"books": {
					"0": {
						"name": "tmp"
					}
				}
			}
		}
	}
	current:= {
		"aid": {
			"value": 0,
			"dbName": "accountAndBooks",
			"table": "accounts",
			"key": "aid"
		},
		"bid": {
			"value": 0,
			"dbName": "accountAndBooks",
			"table": "books",
			"key": "bid"
		}
	}
}

native channel setRecord(dbName: Str, tableName: Str) {
	out db.{dbName}.tables.{tableName}(curRecord: Json, setRecord(newRecord: Json)) = newRecord
}

native channel updateRecordOnChangeCurrent(varName: Str) {
	in current.{varName}.value(currentData, updateRecord(newCurrentData)) = newCurrentData 
}

channel updateCurrent(varName: Str) {
	out current.{varName}.value(curValue: Int, setValue(newValue: Int)) = newValue
}