Query Key Values

I currently have a data table that that uses key/values similar to this: 

 

param_table{

id,

taskId,

key,

value

}

row1 {

1,

123,

"string",

1

}

 

row2{

2,

123,

"string2",

2

}

 

I need to return taskId based on key{string,string2} & value{1,2}. What would be the best way to do this? 

  Discussion posts and replies are publicly visible

Parents
  • Something like this might work if you have an ordered key and value list:

    a!queryEntity(
      entity: <yourentity>,
      query: a!query(
        selection: "taskId",
        logicalExpression: a!queryLogicalExpression(
          logicalExpressions: a!forEach(
            items: <yourkeylist>,
            expression: a!queryLogicalExpression(
              operator: "=",
              filters: a!queryFilter(
                field: "key",
                operator: "=",
                value: <yourvaluelist>[fv!index]
              )
            )
          )
        ),
        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: -1, sort: {})
      )
    )

     

    Let me tell you why this is a good way to implement this solution.

    1. You're limiting the data being retrieved with the selection: "taskId". Loading less data is more efficient.

    2. You're setting the filters up front which also limits the data being retrieved. This is a more efficient solution than loading the data in and trying to iterate it with wherecontains() or other functions.

    Always try and reduce the dataset up front so you retrieve only the needed data.

Reply
  • Something like this might work if you have an ordered key and value list:

    a!queryEntity(
      entity: <yourentity>,
      query: a!query(
        selection: "taskId",
        logicalExpression: a!queryLogicalExpression(
          logicalExpressions: a!forEach(
            items: <yourkeylist>,
            expression: a!queryLogicalExpression(
              operator: "=",
              filters: a!queryFilter(
                field: "key",
                operator: "=",
                value: <yourvaluelist>[fv!index]
              )
            )
          )
        ),
        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: -1, sort: {})
      )
    )

     

    Let me tell you why this is a good way to implement this solution.

    1. You're limiting the data being retrieved with the selection: "taskId". Loading less data is more efficient.

    2. You're setting the filters up front which also limits the data being retrieved. This is a more efficient solution than loading the data in and trying to iterate it with wherecontains() or other functions.

    Always try and reduce the dataset up front so you retrieve only the needed data.

Children
No Data