Sql Queries/Sql Datapoint Confusion
-
I'm storing test files in the jsondata table in the H2 database. Each test file gets its own row. I need a way, from javascript, to query the table for a specific test (row) so I can extract data from the "Data" Column. I understand that you can input the xid into the ma-json-store directive, but this won't work for me because the filenames can't be hardcoded. I'm not sure how to do this and I've been trying/looking at all of the docs for a few days now. An example of what my jsondata table looks like is:
JSONDATA
I'm able to insert and extract data from the row with the name "filename". For instance I can add to and get filenames from the jsonobject under the "DATA" Column. However, once I retrieve the filename from code, I don't know how to use it to get the corresponding row's data. An sql query to do what I want would be:
select data from jsondata where name='<name of desired file>' . But I can't figure out how to achieve this using sql_datapoints/datasources/the ma-json-store directive. Thanks for your help. -
OK I guess the big question is where are you trying to extract this data to? Are you trying to display this on a custom page or something?
select data from jsondata where name='<name of desired file>'
The direct analog of this SQL you provided for a dashboard is<ma-json-store xid="name of desired file" item="myItem" value="data"></ma-json-store>
-
@jared-wiltshire Yes a custom page. I'm using the loginPageTemplate. I don't think using the ma-json-store directive as you wrote it will work because then the filename is still hardcoded. Unless there's a way to pass a variable to the xid attribute? Sorry I'm not experienced with html/javascript. I've tried that exact code, but it doesn't seem to work with a variable passed in. The only other way I can think of doing it is putting all my data in the same row.
-
Hi avilla,
Are you putting your variable name into
{{ }}
to evaluate it?This works for me,
<ma-calc input='"mangoUI-menu"' output="output"></ma-calc> <ma-json-store xid="{{output}}" item="myItem" value="data">{{myItem}}</ma-json-store>