{"componentChunkName":"component---src-templates-default-template-tsx","path":"/documentation/api/list-api/","result":{"data":{"asciidoc":{"id":"48f9581b-5ff8-5334-97d3-398ab0e499da","html":"<div class=\"sect1\">\n<h2 id=\"_hiro_graph_list_api\">HIRO Graph List API</h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>The list API allows one to maintain multiple values for one property.\nA property normally looks like:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">{ \"ogit/name\": \"HIRO\" }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>A listified property looks like</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">{\"ogit/name\": [{\"value\": \"foo\"}, {\"value\": \"bar\", \"created\": 1523360364631}]}</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>whereas the inner structure is actually stored as stringified JSON:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">{\"ogit/name\": [{\"value\":\"foo\"}, {\"value\":\"bar\", \"created\":1523360364631}]}</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>In order to work with list values, the normal API calls can be used, with prefixed field names.\nIn order to read listified values as list, parameter <code>listMeta</code> should be used.</p>\n</div>\n<div class=\"paragraph\">\n<p>Once a value is converted to list it stays as list, but it is still allows to manipulate the list values\nas a normal value. In that case a list is replaced with a new one element list (see examples).</p>\n</div>\n<div class=\"paragraph\">\n<p>EXAMPLE of reading:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-req\" data-lang=\"req\">GET https://{url}/{id}?listMeta=true</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>If <code>created</code> key was not set, it will be added automatically set to now in milliseconds.</p>\n</div>\n<div class=\"sect2\">\n<h3 id=\"_setting_the_contents_of_a_list\">Setting the contents of a list</h3>\n<div class=\"paragraph\">\n<p>By using <code>=</code> as the first key to a property name, one will set the values of the list removing all others.</p>\n</div>\n<div class=\"paragraph\">\n<p>BEFORE:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": \"hello\"\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>UPDATE json:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"=ogit/name\": [{\"value\": \"foo\"}, {\"value\": \"bar\"}]\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>AFTER with <code>listMeta</code>:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": [{\"value\": \"foo\", \"created\": 1523360364631}, {\"value\": \"bar\", \"created\": 1523360364631}]\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>AFTER without <code>listMeta</code>:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": \"[\\\"foo\\\", \\\"bar\\\"]\"\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>Update in backwards-compatible mode</p>\n</div>\n<div class=\"paragraph\">\n<p>BEFORE:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": [{\"value\": \"foo\", \"created\": 1523360364000}]\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>UPDATE json:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": \"bar\"\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>AFTER with <code>listMeta</code>:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": [{\"value\": \"bar\", \"created\": 1523360364635}]\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>AFTER without <code>listMeta</code>:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    // one element list is represented as scalar element\n    \"ogit/name\": \"bar\"\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>Update, which doesn&#8217;t change meta of values:</p>\n</div>\n<div class=\"paragraph\">\n<p>BEFORE:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": [{\"value\": \"foo\", \"created\": 1523360364000}]\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>UPDATE json:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    // If 'created' field is not specified by update, and value exists in a list,\n    // it will not get new `created` timestamp\n    \"=ogit/name\": [{\"value\": \"foo\"}]\n    // OR\n    \"ogit/name\": \"foo\"\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>AFTER with <code>listMeta</code>:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": [{\"value\": \"foo\", \"created\": 1523360364000}\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>AFTER without <code>listMeta</code>:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    // one element list is represented as scalar element\n    \"ogit/name\": \"foo\"\n  }</code></pre>\n</div>\n</div>\n</div>\n<div class=\"sect2\">\n<h3 id=\"_adding_to_the_contents_of_a_list\">Adding to the contents of a list</h3>\n<div class=\"paragraph\">\n<p>By using <code>+</code> as the first key to a property name, one can add one or more values.</p>\n</div>\n<div class=\"paragraph\">\n<p>BEFORE:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": [{\"value\": \"foo\", \"created\": 1523360364631}, {\"value\": \"bar\", \"created\": 1523360364631}]\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>UPDATE json:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"+ogit/name\": [{\"value\": \"foobar\"}]\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>AFTER with <code>listMeta</code>:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": [\n        {\"value\": \"foo\", \"created\": 1523360364631},\n        {\"value\": \"bar\", \"created\": 1523360364631},\n        {\"value\": \"foobar\", \"created\": 1523360364633}\n     ]\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>AFTER without <code>listMeta</code> (order has no garanties):</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": \"[\\\"foobar\\\", \\\"foo\\\", \\\"bar\\\"]\"\n  }</code></pre>\n</div>\n</div>\n</div>\n<div class=\"sect2\">\n<h3 id=\"_removing_from_the_contents_of_a_list\">Removing from the contents of a list</h3>\n<div class=\"paragraph\">\n<p>By using <code>-</code> as the first key to a property name, one can remove one or more values.\nSpecifying properties in the removal call will only remove those items in the list, that match all properties specified by the item to remove.</p>\n</div>\n<div class=\"paragraph\">\n<p>BEFORE:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": [{\"value\": \"foo\", \"created\": 1523360364631}, {\"value\": \"bar\", \"created\": 1523360364631}]\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>UPDATE json:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"-ogit/name\": [{\"value\": \"foo\", \"created\": 1523360364631}, {\"value\": \"bar\", \"created\": 0}]\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>AFTER with <code>listMeta</code>:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": [{\"value\": \"bar\", \"created\": 1523360364631}]\n  }</code></pre>\n</div>\n</div>\n</div>\n<div class=\"sect2\">\n<h3 id=\"_converting_to_list\">Converting to list</h3>\n<div class=\"paragraph\">\n<p>One can create a list by calling any of <code>=</code> on a scalar property value:</p>\n</div>\n<div class=\"paragraph\">\n<p>BEFORE:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": \"foo\"\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>UPDATE json:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"=ogit/name\": [{\"value\": \"foo\", \"created\": 1523360364631}, {\"value\": \"bar\", \"created\": 1523360364631}]\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>AFTER:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": [{\"value\": \"foo\", \"created\": 1523360364631}, {\"value\": \"bar\", \"created\": 1523360364631}]\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>Removing existing scalar property with list API, if value has no <code>created</code> timestamp (not in a list form),\nvertex <code>ogit/_created-on</code> should be used instead:</p>\n</div>\n<div class=\"paragraph\">\n<p>BEFORE:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"ogit/name\": \"foo\",\n    \"ogit/_created-on\": \"15233603640000\"\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>UPDATE json:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n    \"-ogit/name\": [{\"value\": \"foo\", \"created\": 15233603640000}]\n  }</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>AFTER:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-json\" data-lang=\"json\">  {\n  }</code></pre>\n</div>\n</div>\n</div>\n</div>\n</div>","document":{"main":"HIRO Graph List API","title":"HIRO Graph List API","subtitle":""},"fields":{"toc":false,"location":["documentation","api","list-api"]}},"sidebarYaml":{"id":"6d066bdd-c982-5a69-b909-a31e6fc044e0","showIndex":null}},"pageContext":{"id":"48f9581b-5ff8-5334-97d3-398ab0e499da","parent":"documentation"}},"staticQueryHashes":["1010459453","1010459453","2356112386","2356112386","2603905930","2603905930","3026652197","3026652197","3167850324","3167850324","63159454","63159454"]}