I have a proc that returns json rows: 
    
    
    proc getJsonRows*(db: DbConn, query:SqlQuery, args: varargs[string, `$`]): 
JsonNode =
        result = newJArray()
        var columns: DbColumns
        for row in db.instantRows(columns, query, args):
            var tmpobj = newJObject()
            for i in 0..<columns.len:
              var
                colname = columns[i].name
                colval = %* row[i.int32]
              tmpobj.add(colname, colval)
            result.add(tmpobj)
    
    
    Run

Just wondering what other more efficient alternatives there might be or if 
there is any feedback.

I'm using Jester to serve data like: 
    
    
    
[{"Month":"2021-01","Location":"AL","Values":"12345"},{"Month":"2021-01","Location":"BE","Values":"12345"}]
    
    
    Run

It is nice because vega-lite fetches the data based on url: 
    
    
    var vlSpec = """{
            "$schema": "https://vega.github.io/schema/vega-lite/v5.json";,
            "config": {
                "aria": true,
                "axis": {"titleFontSize": 16, "labelFontSize": 14},
                "title": {"fontSize": 25}
            },
            "data": {"url": "/v1/data/circ2"}... #
    
    
    Run

Reply via email to