Loading TOC...

MarkLogic 12 EA 2 Product Documentation
map:count

map:count(
   $map as map:map
) as xs:unsignedInt

Summary

Returns the number of keys used in the map.

Parameters
map A map.

Example

  (: assume $table is bound to a map with 15 keys :)
  map:count($table)
  => 15

Example

let $map := map:map()
let $_map := map:put($map, "a", 1)
let $_map := map:put($map, "a", 2)
let $_map := map:put($map, "b", 1)
let $_map := map:put($map, "b", 2)
return
($map, map:count($map))
=>
map:map(
  <map:map xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:map="http://marklogic.com/xdmp/map">
    <map:entry key="b">
      <map:value xsi:type="xs:integer">2</map:value>
    </map:entry>
    <map:entry key="a">
      <map:value xsi:type="xs:integer">2</map:value>
    </map:entry>
  </map:map>)
2

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.