Unique Index

To look up data from the unique index:

    unique(data_source_name: str, index_name: str, query: str) -> Option<Map>
  • data_source_name is the name you gave your lookup table
  • index_name is the name of the unique index you wish to query
  • query is the value that the index will search for
  • The return value is either a Map object containing the matched row or ()

A query from our example table from earlier could look like this:

    let value = unique("products", "code", "CLAY-2K");
    /*
        value = #{
            "Product Code": "CLAY-2K",
            "Tag": "clay",
            "Weight": "2000.0",
            "Unit": "g"
        }
    */