Hyperledger Composer: How to query using string?

0 votes

I have a structure defined like that:

concept Data
{
  o Double Temp
  o Double Hum
}

asset Reading identified by ReadingID
{
    o String ReadingID
    o String DeviceID
    o Integer Time
    o Data Data
}

In Composer, I can search for ReadingID without coding anything, because it is the "primary key" and this query is automatically defined.

Is there a way for querying using basic types, like a String?

Nov 9, 2018 in Blockchain by digger
• 26,550 points
49 views

1 answer to this question.

0 votes

You can try this:

query selectReading {
  description: "my query"
  statement:
      SELECT org.acme.biznet.Reading
          WHERE (DeviceID ==_$device_id)
}


return query('selectReading', {device_id: device} )
// return query('selectReading', {device_id: '1234567'} )
        .then(function (results) {


           for (var n = 0; n < results.length; n++) {
            // process array of results
           }
       });
answered Nov 9, 2018 by Omkar
• 67,660 points

Related Questions In Blockchain

+1 vote
1 answer
0 votes
1 answer

How to solve EACCES:permission denied error in Hyperledger Composer?

It seems like there is no required ...READ MORE

answered Jul 11, 2018 in Blockchain by digger
• 26,550 points
422 views
0 votes
1 answer
+1 vote
1 answer

I am unable to change port of composer-rest-server. Please help!

Use full format for running a business ...READ MORE

answered Mar 27, 2018 in Blockchain by Christine
• 15,790 points
304 views
+1 vote
1 answer
0 votes
1 answer

Hyperledger composer: How to include relationship in custom query?

You are trying to use filter={"include":"resolve"} in Composer Query. ...READ MORE

answered Nov 16, 2018 in Blockchain by Omkar
• 67,660 points
402 views
0 votes
1 answer

How to get TimeStamps in Hyperledger Composer?

Here's an example that works with basic-sample-network network: asset SampleAsset ...READ MORE

answered Oct 26, 2018 in Blockchain by Omkar
• 67,660 points
278 views