Use Node-RED to add & query records
Complete the tutorial requirements before this procedure.
Query data
Drag an inject node into the flow.
Connect the output of the inject node to the input of the Add auth token node that the createTable node feeds into.
Double-click the inject node to edit it.
Enter
getRecordsStartingAtKey
in the Name textbox.Enter
{} JSON
in the msg.payload textbox.Click
to open the JSON editor.Paste the following JSON in the JSON editor textbox:
{ "api": "db", "authToken": "replaceWithRealToken", "action": "getRecordsStartingAtKey", "params": { "databaseName": "ctreeSQL", "tableName": "athlete", "indexFilter": { "indexName": "ranking", "operator": ">=", "indexFields": [ { "fieldName": "ranking", "value": 3 } ] }, "reverseOrder": false } }
Click
to close the JSON editor.
Click FairCom Edge server instructing it to return records where
to configure the inject node to send a JSON object to the"ranking"
is equal to or greater than three.Click the corresponding createIndex node button to send the request.
Observe the results in the debug tab.
Note
"errorCode"
with a value of0
indicates success."errorCode"
with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.Click the
"msg.payload"
object in the debug tab.Expand the
"result"
property.Expand the
"data"
property to view the list of four objects (numbered 0-3).Expand the
0
object to view the first row returned by the query.