<!DOCTYPE html><!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--><!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>API design style guide — APIJSON Docs 1.0.0 documentation</title><script type="text/javascript" src="../_static/js/modernizr.min.js"></script><script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script><script type="text/javascript" src="../_static/jquery.js"></script><script type="text/javascript" src="../_static/underscore.js"></script><script type="text/javascript" src="../_static/doctools.js"></script><script type="text/javascript" src="../_static/language_data.js"></script><script type="text/javascript" src="../_static/contentui.js"></script><script type="text/javascript" src="../_static/js/theme.js"></script><link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /><link rel="stylesheet" href="../_static/pygments.css" type="text/css" /><link rel="stylesheet" href="../_static/css/custom.css" type="text/css" /><link rel="stylesheet" href="../_static/contentui.css" type="text/css" /><link rel="index" title="Index" href="../genindex.html" /><link rel="search" title="Search" href="../search.html" /><link rel="next" title="How does APIJSON works?" href="why.html" /><link rel="prev" title="Client-side Deployment" href="../quick_start/client_deployment/client_deployment.html" /></head><body class="wy-body-for-nav"><div class="wy-grid-for-nav"><nav data-toggle="wy-nav-shift" class="wy-nav-side"><div class="wy-side-scroll"><div class="wy-side-nav-search" ><a href="../index.html" class="icon icon-home"> APIJSON Docs</a><div role="search"><form id="rtd-search-form" class="wy-form" action="../search.html" method="get"><input type="text" name="q" placeholder="Search docs" /><input type="hidden" name="check_keywords" value="yes" /><input type="hidden" name="area" value="default" /></form></div></div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"><p class="caption"><span class="caption-text">Quick Start</span></p><ul><li class="toctree-l1"><a class="reference internal" href="../quick_start/introduction.html">About APIJSON</a></li><li class="toctree-l1"><a class="reference internal" href="../quick_start/features.html">Features</a></li><li class="toctree-l1"><a class="reference internal" href="../quick_start/server_deployment/server_deployment.html">Server-side Deployment</a></li><li class="toctree-l1"><a class="reference internal" href="../quick_start/client_deployment/client_deployment.html">Client-side Deployment</a></li></ul><p class="caption"><span class="caption-text">Documentation</span></p><ul class="current"><li class="toctree-l1 current"><a class="current reference internal" href="#">API design style guide</a><ul><li class="toctree-l2"><a class="reference internal" href="#apijson-methods">1. APIJSON Methods</a><ul><li class="toctree-l3"><a class="reference internal" href="#get"><strong>GET</strong> :</a></li><li class="toctree-l3"><a class="reference internal" href="#head"><strong>HEAD</strong> :</a></li><li class="toctree-l3"><a class="reference internal" href="#gets"><strong>GETS</strong> :</a></li><li class="toctree-l3"><a class="reference internal" href="#heads"><strong>HEADS</strong> :</a></li><li class="toctree-l3"><a class="reference internal" href="#post"><strong>POST</strong> :</a></li><li class="toctree-l3"><a class="reference internal" href="#put"><strong>PUT</strong> :</a></li><li class="toctree-l3"><a class="reference internal" href="#delete"><strong>DELETE</strong> :</a></li></ul></li><li class="toctree-l2"><a class="reference internal" href="#functional-key-value-pairs">2. Functional Key-Value Pairs</a></li><li class="toctree-l2"><a class="reference internal" href="#build-in-string-functions-part-one">3. Build-in string functions part one</a></li><li class="toctree-l2"><a class="reference internal" href="#build-in-string-functions-part-two">4. Build-in string functions part two</a></li></ul></li><li class="toctree-l1"><a class="reference internal" href="why.html">How does APIJSON works?</a></li><li class="toctree-l1"><a class="reference internal" href="what_achieved.html">What APIJSON has achieved?</a></li></ul></div></div></nav><section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="top navigation"><i data-toggle="wy-nav-top" class="fa fa-bars"></i><a href="../index.html">APIJSON Docs</a></nav><div class="wy-nav-content"><div class="rst-content"><div role="navigation" aria-label="breadcrumbs navigation"><ul class="wy-breadcrumbs"><li><a href="../index.html">Docs</a> »</li><li>API design style guide</li><li class="wy-breadcrumbs-aside"><a href="../_sources/documentation/design_rules.rst.txt" rel="nofollow"> View page source</a></li></ul><hr/></div><div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"><div itemprop="articleBody"><div class="section" id="api-design-style-guide"><h1>API design style guide<a class="headerlink" href="#api-design-style-guide" title="Permalink to this headline">¶</a></h1><p>This chapter introduces methods in APIJSON. These methods are:</p><table class="docutils align-default"><colgroup><col style="width: 31%" /><col style="width: 69%" /></colgroup><tbody><tr class="row-odd"><td><p><a class="reference internal" href="#getdef"><span class="std std-ref">GET</span></a></p></td><td><p>It provides a general way to retrieve resources.</p></td></tr><tr class="row-even"><td><p><a class="reference internal" href="#headdef"><span class="std std-ref">HEAD</span></a></p></td><td><p>It provides a general way to count resources satisfyingspecifics in the request body.</p></td></tr><tr class="row-odd"><td><p><a class="reference internal" href="#getsdef"><span class="std std-ref">GETS</span></a></p></td><td><p>It requests for highly secured and confidential datalike bank accounts, birth dates.</p></td></tr><tr class="row-even"><td><p><a class="reference internal" href="#headsdef"><span class="std std-ref">HEADS</span></a></p></td><td><p>It’s used for getting counts of highly securedresources(eg. bank accounts).</p></td></tr><tr class="row-odd"><td><p><a class="reference internal" href="#postdef"><span class="std std-ref">POST</span></a></p></td><td><p>It creates new resources under the specified parentresource(TableName).</p></td></tr><tr class="row-even"><td><p><a class="reference internal" href="#putdef"><span class="std std-ref">PUT</span></a></p></td><td><p>This method asks the server to update/edit an existingresource.</p></td></tr><tr class="row-odd"><td><p><a class="reference internal" href="#deletedef"><span class="std std-ref">DELETE</span></a></p></td><td><p>This method deletes the specified resource.</p></td></tr></tbody></table><p>Request method tells the server what kind of action the client wants the server to take. The method are also commonly referred to as the request "verb". This chapter will show you how these methods are included in url to send requests.</p><p>In the following explanations, the <em>base_URL</em> means the root URL. Everything that follows it is known as a URL path. All URL paths are relative to the base URL.</p><div class="section" id="apijson-methods"><h2>1. APIJSON Methods<a class="headerlink" href="#apijson-methods" title="Permalink to this headline">¶</a></h2><div class="section" id="get"><span id="getdef"></span><h3><strong>GET</strong> :<a class="headerlink" href="#get" title="Permalink to this headline">¶</a></h3><p>A general way to retrieve resources.</p><p><span class="blue">base_url/get/</span></p><div class="content-tabs docutils container"><div class="tab-content docutils container" id="tab-tab1"><p class="tab-title">Request</p><blockquote><div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="p">{</span><span class="s2">"TableName"</span><span class="p">{</span><span class="o">//</span> <span class="n">conditions</span><span class="p">}</span><span class="p">}</span><span class="o">//</span> <span class="n">eg</span><span class="o">.</span> <span class="n">Request</span> <span class="n">a</span> <span class="n">post</span> <span class="k">with</span> <span class="nb">id</span> <span class="o">=</span> <span class="mi">235</span> <span class="ow">in</span> <span class="n">table</span> <span class="s2">"Post"</span><span class="p">:</span><span class="p">{</span><span class="s2">"Post"</span><span class="p">{</span><span class="s2">"id"</span><span class="p">:</span> <span class="mi">235</span><span class="p">}</span><span class="p">}</span></pre></div></div></div></blockquote></div><div class="tab-content docutils container" id="tab-tab2"><p class="tab-title">Response</p><blockquote><div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span> {"TableName":{...},"code":200,"msg":"success"}// eg. The returned response:{"Moment":{"id":235,"userId":38710,"content":"..."},"code":200,"msg":"success"}</pre></div></div></div></blockquote></div></div></div><div class="section" id="head"><span id="headdef"></span><h3><strong>HEAD</strong> :<a class="headerlink" href="#head" title="Permalink to this headline">¶</a></h3><p>A general way to count resources satisfying specifics in the request body.</p><p><span class="blue">base_url/head/</span></p><div class="content-tabs docutils container"><div class="tab-content docutils container" id="tab-tab1"><p class="tab-title">Request</p><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="s2">"TableName"</span><span class="p">:{</span><span class="o">//</span> <span class="n">conditions</span><span class="p">}</span><span class="p">}</span><span class="o">//</span> <span class="n">eg</span><span class="o">.</span> <span class="n">Get</span> <span class="n">the</span> <span class="n">number</span> <span class="n">of</span> <span class="n">posts</span> <span class="n">posted</span> <span class="n">by</span> <span class="n">the</span> <span class="n">user</span> <span class="n">whose</span> <span class="nb">id</span> <span class="o">=</span> <span class="mi">38710</span><span class="p">:</span><span class="p">{</span><span class="s2">"Post"</span><span class="p">:{</span><span class="s2">"userId"</span><span class="p">:</span><span class="mi">38710</span><span class="p">}</span><span class="p">}</span></pre></div></div></div><div class="tab-content docutils container" id="tab-tab2"><p class="tab-title">Response</p><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="s2">"TableName"</span><span class="p">:{</span><span class="s2">"code"</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span><span class="s2">"msg"</span><span class="p">:</span><span class="s2">"success"</span><span class="p">,</span><span class="s2">"count"</span><span class="p">:</span><span class="o">...</span><span class="p">},</span><span class="s2">"code"</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span><span class="s2">"msg"</span><span class="p">:</span><span class="s2">"success"</span><span class="p">}</span><span class="o">//</span> <span class="n">eg</span><span class="o">.</span><span class="p">{</span><span class="s2">"Post"</span><span class="p">:{</span><span class="s2">"code"</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span> <span class="s2">"msg"</span><span class="p">:</span><span class="s2">"success"</span><span class="p">,</span> <span class="s2">"count"</span><span class="p">:</span><span class="mi">10</span><span class="p">},</span><span class="s2">"code"</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span><span class="s2">"msg"</span><span class="p">:</span><span class="s2">"success"</span><span class="p">}</span></pre></div></div></div></div></div><div class="section" id="gets"><span id="getsdef"></span><h3><strong>GETS</strong> :<a class="headerlink" href="#gets" title="Permalink to this headline">¶</a></h3><p>Request for highly secured and confidential data like bank accounts, birth dates.</p><p><span class="blue">base_url/gets/</span></p><div class="content-tabs docutils container"><div class="tab-content docutils container" id="tab-tab1"><p class="tab-title">Request</p><blockquote><div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span>// You need to nest a key-value pair"tag": tag// at the top level of the request json object. The tag is usually the related table's name.//Except that, the structure is the same as **GET**.</pre></div></div></div></blockquote></div><div class="tab-content docutils container" id="tab-tab2"><p class="tab-title">Response</p><blockquote><div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">//</span> <span class="n">Same</span> <span class="k">as</span> <span class="o">**</span><span class="n">GET</span><span class="o">**</span></pre></div></div></div></blockquote></div></div></div><div class="section" id="heads"><span id="headsdef"></span><h3><strong>HEADS</strong> :<a class="headerlink" href="#heads" title="Permalink to this headline">¶</a></h3><p>It’s used for getting counts of highly secured resources(eg. bank accounts).</p><p><span class="blue">base_url/heads/</span></p><div class="content-tabs docutils container"><div class="tab-content docutils container" id="tab-tab1"><p class="tab-title">Request</p><div class="highlight-default notranslate"><div class="highlight"><pre><span></span>// You need to nest a key-value pair"tag": tag// at the top level of the request json object.//Except that, the structure is the same as **HEAD**.</pre></div></div></div><div class="tab-content docutils container" id="tab-tab2"><p class="tab-title">Response</p><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>// Same as **HEAD**.</pre></div></div></div></div></div><div class="section" id="post"><span id="postdef"></span><h3><strong>POST</strong> :<a class="headerlink" href="#post" title="Permalink to this headline">¶</a></h3><p>The <strong>POST</strong> method creates new resources under the specified parent resource(TableName).</p><p><span class="blue">base_url/post/</span></p><div class="content-tabs docutils container"><div class="tab-content docutils container" id="tab-tab1"><p class="tab-title">Request</p><div class="highlight-default notranslate"><div class="highlight"><pre><span></span>{"TableName":{...},"tag":tag}// Note the id in the object "TableName":{...} has been generated automatically when table is built and can’t be set by the user here.// eg. A user with id = 38710 posts a new post:{"Post":{"userId":38710,"content":"APIJSON lets interfaces and documents go hell!"},"tag":"Moment"}</pre></div></div></div><div class="tab-content docutils container" id="tab-tab2"><p class="tab-title">Response</p><div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="p">{</span><span class="s2">"Moment"</span><span class="p">:{</span><span class="s2">"code"</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span><span class="s2">"msg"</span><span class="p">:</span><span class="s2">"success"</span><span class="p">,</span><span class="s2">"id"</span><span class="p">:</span><span class="o">...</span><span class="p">},</span><span class="s2">"code"</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span><span class="s2">"msg"</span><span class="p">:</span><span class="s2">"success"</span><span class="p">}</span><span class="o">//</span> <span class="n">If</span> <span class="n">the</span> <span class="n">request</span> <span class="ow">is</span> <span class="n">successful</span><span class="p">,</span> <span class="n">it</span> <span class="n">should</span> <span class="k">return</span> <span class="n">following</span> <span class="nb">object</span><span class="o">.</span><span class="p">{</span><span class="n">TableName</span><span class="p">:{</span><span class="s2">"code"</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span><span class="s2">"msg"</span><span class="p">:</span><span class="s2">"success"</span><span class="p">,</span><span class="s2">"id"</span><span class="p">:</span><span class="mi">38710</span><span class="p">},</span><span class="s2">"code"</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span><span class="s2">"msg"</span><span class="p">:</span><span class="s2">"success"</span><span class="p">}</span></pre></div></div></div></div></div><div class="section" id="put"><span id="putdef"></span><h3><strong>PUT</strong> :<a class="headerlink" href="#put" title="Permalink to this headline">¶</a></h3><p>The <strong>PUT</strong> method asks the server to update/edit an existing resource. The part that will be modified is included in the request body.</p><p><span class="blue">base_url/put/</span></p><div class="content-tabs docutils container"><div class="tab-content docutils container" id="tab-tab1"><p class="tab-title">Request</p><div class="highlight-default notranslate"><div class="highlight"><pre><span></span> {"TableName":{"id":id,...},"tag":tag}// You need to either specify the id in the TableName object like the example above or add a id{} object in the request body.// The following example makes request to update the content made by id = 235:{"Post":{"id":235,"content":"APIJSON lets interfaces and documents go hell !"},"tag":"Post"}</pre></div></div></div><div class="tab-content docutils container" id="tab-tab2"><p class="tab-title">Response</p><blockquote><div><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>\\ Same as **POST**.</pre></div></div></div></blockquote></div></div></div><div class="section" id="delete"><span id="deletedef"></span><h3><strong>DELETE</strong> :<a class="headerlink" href="#delete" title="Permalink to this headline">¶</a></h3><p>The <strong>DELETE</strong> method deletes the specified resource.</p><p><span class="blue">base_url/delete/</span></p><div class="content-tabs docutils container"><div class="tab-content docutils container" id="tab-tab1"><p class="tab-title">Request</p><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="n">TableName</span><span class="p">:{</span><span class="s2">"id"</span><span class="p">:</span><span class="nb">id</span><span class="p">},</span><span class="s2">"tag"</span><span class="p">:</span><span class="n">tag</span><span class="p">}</span><span class="o">//</span> <span class="n">You</span> <span class="n">need</span> <span class="n">to</span> <span class="n">either</span> <span class="n">specify</span> <span class="n">the</span> <span class="nb">id</span> <span class="ow">in</span> <span class="n">the</span> <span class="n">TableName</span> <span class="nb">object</span> <span class="n">like</span> <span class="n">the</span> <span class="n">example</span> <span class="n">above</span> <span class="ow">or</span> <span class="n">add</span> <span class="n">a</span> <span class="nb">id</span><span class="p">{}</span> <span class="nb">object</span> <span class="ow">in</span> <span class="n">the</span> <span class="n">request</span> <span class="n">body</span><span class="o">.</span><span class="o">//</span> <span class="n">The</span> <span class="n">following</span> <span class="n">example</span> <span class="n">send</span> <span class="n">a</span> <span class="n">request</span> <span class="n">to</span> <span class="n">delete</span> <span class="n">comments</span> <span class="n">made</span> <span class="n">by</span> <span class="nb">id</span> <span class="o">=</span> <span class="mi">100</span><span class="p">,</span><span class="mi">110</span><span class="p">,</span><span class="mi">120</span><span class="p">{</span><span class="s2">"Comment"</span><span class="p">:{</span><span class="s2">"id</span><span class="si">{}</span><span class="s2">"</span><span class="p">:[</span><span class="mi">100</span><span class="p">,</span><span class="mi">110</span><span class="p">,</span><span class="mi">120</span><span class="p">]</span><span class="p">},</span><span class="s2">"tag"</span><span class="p">:</span><span class="s2">"Comment[]"</span><span class="p">}</span></pre></div></div></div><div class="tab-content docutils container" id="tab-tab2"><p class="tab-title">Response</p><div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="p">{</span><span class="s2">"TableName"</span><span class="p">:{</span><span class="s2">"code"</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span><span class="s2">"msg"</span><span class="p">:</span><span class="s2">"success"</span><span class="p">,</span><span class="s2">"id[]"</span><span class="p">:[</span><span class="o">...</span><span class="p">]</span><span class="s2">"count"</span><span class="p">:</span><span class="mi">3</span><span class="p">},</span><span class="s2">"code"</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span><span class="s2">"msg"</span><span class="p">:</span><span class="s2">"success"</span><span class="p">}</span><span class="o">//</span> <span class="n">The</span> <span class="n">response</span> <span class="n">to</span> <span class="n">the</span> <span class="n">request</span> <span class="ow">in</span> <span class="n">the</span> <span class="n">example</span> <span class="n">above</span><span class="p">{</span><span class="s2">"Comment"</span><span class="p">:{</span><span class="s2">"code"</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span><span class="s2">"msg"</span><span class="p">:</span><span class="s2">"success"</span><span class="p">,</span><span class="s2">"id[]"</span><span class="p">:[</span><span class="mi">100</span><span class="p">,</span><span class="mi">110</span><span class="p">,</span><span class="mi">120</span><span class="p">],</span><span class="s2">"count"</span><span class="p">:</span><span class="mi">3</span><span class="p">},</span><span class="s2">"code"</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span><span class="s2">"msg"</span><span class="p">:</span><span class="s2">"success"</span><span class="p">}</span></pre></div></div></div></div><p><strong>Note:</strong></p><blockquote><div><ol class="arabic simple"><li><p><em>TableName</em> means the name of the table that a user interacts with. It’s a string with the first letter capitalized. It can be any combination of letters, numbers and underscores. As a key, its value is a jsonObject which may include columns’ names in the table.</p></li><li><p><code class="code docutils literal notranslate"><span class="pre">"tag":tag</span></code> needs to be included when the request method is neither <strong>GET</strong> nor <strong>HEAD</strong>. The value <em>tag</em> is the key of the returned jsonObject in the response body. Usually, it’s the name of the related table.</p></li><li><p>The request form under <strong>GET</strong> and <strong>HEAD</strong> methods are very flexible. The request jsonObject can be nested many levels. However, other methods need to be constrained by adding tags, etc. The structure of the request body needs to conform resources at the backend.</p></li><li><p><strong>GETS</strong> and <strong>GET</strong>, <strong>HEADS</strong> and <strong>HEAD</strong> are the same type of operation. For both groups, the request bodies have something different, while the response bodies are the same.</p></li><li><p>When transmit through HTTP protocal, all the API methods (get,gets,head,heads,post,put,delete) use HTTP <strong>POST</strong> verb.</p></li><li><p>All jsonObjects are seen as variables or folders with the form of <code class="code docutils literal notranslate"><span class="pre">{...}</span></code>. It can store objects or associative arrays.</p></li><li><p>Each object is related to an individually-addressable resource which has an unique address.</p></li></ol></div></blockquote></div></div><div class="section" id="functional-key-value-pairs"><h2>2. Functional Key-Value Pairs<a class="headerlink" href="#functional-key-value-pairs" title="Permalink to this headline">¶</a></h2><p><strong>Get data in an array:</strong> <code class="code docutils literal notranslate"><span class="pre">/get/{"key[]":{"tableName":{}}}</span></code></p><p>The part after the colon is a JSONObject. The <code class="code docutils literal notranslate"><span class="pre">key</span></code> is optional. When <code class="code docutils literal notranslate"><span class="pre">key</span></code> is as the same as the <code class="code docutils literal notranslate"><span class="pre">tableName</span></code>, the JSONObject will be in a simplified form. For example: <code class="code docutils literal notranslate"><span class="pre">{"User[]":{"User":{"id",...}}}</span></code> will be written as <code class="code docutils literal notranslate"><span class="pre">{"User[]":{"id",...}}</span></code>.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:3,%22User%22:%7B%7D%7D%7D">/get/{"User[]":{"count":3,"User":{}}}</a></p><p>In this example, the request is to <strong>GET</strong> 3 users’ information. The response includes 3 users information with all categories saved in an array.</p></div></blockquote></div><hr class="docutils" /><p><strong>Get filtered data:</strong> <code class="code docutils literal notranslate"><span class="pre">/get/{"key[]":{"tableName":{"key2{}":[]}}}</span></code></p><p>Specifically in this part: <code class="code docutils literal notranslate"><span class="pre">"key2{}":[]</span></code>, the part after the colon is a JSONArray which contains <code class="code docutils literal notranslate"><span class="pre">key2</span></code>’s values. This part is to specify the conditions that the return should satisfy.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:3,%22User%22:%7B%22id%7B%7D%22:%5B38710,82001,70793%5D%7D%7D%7D">/get/{"User[]":{"count":3,"User":{"id{}":[38710,82001,70793]}}}</a></p><p>This example shows how to get users’s information with id equals 38710,82001,70793.</p></div></blockquote></div><hr class="docutils" /><p><strong>Get data with comparison operation:</strong> <code class="code docutils literal notranslate"><span class="pre">/get/{"key[]":{"tableName":{"id{}":"<=80000,>90000"}}}</span></code></p><p>Just as the comparison operation functions in SQL, it’s used here to get resources in a range. It dosn’t need to be numbers though.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:3,%22User%22:%7B%22id%7B%7D%22:%22%3C=80000,%3E90000%22%7D%7D%7D">/get/{"User[]":{"count":3,"User":{"id{}":"<=80000,>90000"}}}</a></p><p>In SQL, it’d be <code class="code docutils literal notranslate"><span class="pre">id<=80000</span> <span class="pre">OR</span> <span class="pre">id>90000</span></code>, which means get User array with id<=80000 | id>90000</p></div></blockquote></div><hr class="docutils" /><p><strong>Get data that contains an element:</strong> <code class="code docutils literal notranslate"><span class="pre">/get/{"key[]":{"User":{"key2<>":[object]}}}</span></code></p><p>This also used when the user wants to get data that meets specific conditions. <code class="code docutils literal notranslate"><span class="pre">key2</span></code> must be a JSONArray while <code class="code docutils literal notranslate"><span class="pre">object</span></code> cannot be JSON.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:3,%22User%22:%7B%22contactIdList%3C%3E%22:38710%7D%7D%7D">"/get/{"User[]":{"count":3,"User":{"contactIdList<>":38710}}}":38710</a></p><p>In this example, it requests 3 User arrays whose contactIdList contains 38710. In SQL, this would be <code class="code docutils literal notranslate"><span class="pre">json_contains(contactIdList,38710)</span></code>.</p></div></blockquote></div><hr class="docutils" /><p><strong>See if it exists</strong> <code class="code docutils literal notranslate"><span class="pre">/get/{"key":{"key2}{@":{"from":"tableName","tableName":{...}}}}</span></code></p><p>In this request url, <em>}{</em> means EXISTS; <em>key2</em> is the item you want to check.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><dl class="simple"><dt><a href="#id1"><span class="problematic" id="id2">`</span></a>{"User":</dt><dd><dl class="simple"><dt>{"id}{@":{</dt><dd><p>"from":"Comment","Comment":{"momentId":15}}}} <<a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%22:%7B%22id%7D%7B@%22:%7B%22from%22:%22Comment%22,%22Comment%22:%7B%22momentId%22:15%7D%7D%7D%7D">http://apijson.cn:8080/get/%7B%22User%22:%7B%22id%7D%7B@%22:%7B%22from%22:%22Comment%22,%22Comment%22:%7B%22momentId%22:15%7D%7D%7D%7D</a>>`_</p></dd></dl></dd></dl><p>In this example, the request is to check if the id whose <code class="code docutils literal notranslate"><span class="pre">momentId</span> <span class="pre">=</span> <span class="pre">15</span></code> exists. The SQL form would be <code class="code docutils literal notranslate"><span class="pre">WHERE</span> <span class="pre">EXISTS(SELECT</span> <span class="pre">*</span> <span class="pre">FROM</span> <span class="pre">Comment</span> <span class="pre">WHERE</span> <span class="pre">momentId=15)</span></code></p></div></blockquote></div><hr class="docutils" /><p><strong>Include functions in url parameters</strong> <code class="code docutils literal notranslate"><span class="pre">/get/{"Table":{"key":value,</span> <span class="pre">key()":"function</span> <span class="pre">(key0,key1...)}"</span></code></p><p>This will trigger the back-end function(JSONObject request, String key0, String key1...)to get or testify data.</p><p>Use - and + to show the order of priority: analyze key-() > analyze the current object > analyze key() > analyze child object > analyze key+()</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22Moment%22:%7B%22id%22:301,%22isPraised()%22:%22isContain(praiseUserIdList,userId)%22%7D%7D">/get/{"Moment":{"id":301,"isPraised()":"isContain(praiseUserIdList,userId)"}}</a></p><p>This will use function boolean <code class="code docutils literal notranslate"><span class="pre">isContain(JSONObject</span> <span class="pre">request,</span> <span class="pre">String</span> <span class="pre">array,</span> <span class="pre">String</span> <span class="pre">value)</span></code>. In this case, client will get <code class="code docutils literal notranslate"><span class="pre">"is</span> <span class="pre">praised":</span> <span class="pre">true</span></code> (In this case, client use function to testify if a user clicked ‘like’ button for a post.)</p></div></blockquote></div><hr class="docutils" /><p><strong>Refer a value</strong></p><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>"key@":"key0/key1/.../refKey"</pre></div></div><p>Use forward slash to show the path. The part before the colon is the key that wants to refer. The path after the colon starts with the parent level of the key.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><dl><dt><a href="#id3"><span class="problematic" id="id4">`</span></a>"Moment":{</dt><dd><blockquote><div><p>"userId":38710},</p></div></blockquote><dl class="simple"><dt>"User":{</dt><dd><p>"id@":"/Moment/userId"} <<a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%22:%7B%22id@%22:%7B%22from%22:%22Comment%22,%22Comment%22:%7B%22@column%22:%22min(userId)%22%7D%7D%7D%7D">http://apijson.cn:8080/get/%7B%22User%22:%7B%22id@%22:%7B%22from%22:%22Comment%22,%22Comment%22:%7B%22@column%22:%22min(userId)%22%7D%7D%7D%7D</a>>`_</p></dd></dl></dd></dl><p>In this example, the value of <code class="code docutils literal notranslate"><span class="pre">id</span></code> in <code class="code docutils literal notranslate"><span class="pre">User</span></code> refer to the <code class="code docutils literal notranslate"><span class="pre">userId</span></code> in <code class="code docutils literal notranslate"><span class="pre">Moment</span></code>, which means <code class="code docutils literal notranslate"><span class="pre">User.id</span> <span class="pre">=</span> <span class="pre">Moment.userId</span></code>. After the request is sent, <code class="code docutils literal notranslate"><span class="pre">"id@":"/Moment/userId"</span></code> will be <code class="code docutils literal notranslate"><span class="pre">"id":38710</span></code>.</p></div></blockquote></div><hr class="docutils" /><p><strong>Subquery expression</strong></p><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>"key@":{"range": "ALL","from":"Table","Table":{ ... }}</pre></div></div><p>Range can be <strong>ALL</strong>, <strong>ANY</strong>. It means which table you want to query. It’s very similar to how you query in SQL. You can also use <strong>COUNT</strong>, <strong>JOIN</strong>, etc.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><dl><dt><a href="#id5"><span class="problematic" id="id6">`</span></a>"id@":{</dt><dd><p>"from":"Comment","Comment":{"@column":"min(userId)"</p><blockquote><div><p>}</p></div></blockquote><p>} <<a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%22:%7B%22id@%22:%7B%22from%22:%22Comment%22,%22Comment%22:%7B%22@column%22:%22min(userId)%22%7D%7D%7D%7D">http://apijson.cn:8080/get/%7B%22User%22:%7B%22id@%22:%7B%22from%22:%22Comment%22,%22Comment%22:%7B%22@column%22:%22min(userId)%22%7D%7D%7D%7D</a>>`_</p></dd></dl><dl class="field-list simple"><dt class="field-odd">code</dt><dd class="field-odd"><p><cite>WHERE id=(SELECT min(userId) FROM Comment)</cite></p></dd></dl></div></blockquote></div><hr class="docutils" /><p><strong>Fuzzy matching</strong> <code class="code docutils literal notranslate"><span class="pre">"key$":"SQL</span> <span class="pre">search</span> <span class="pre">expressions"</span></code> => <code class="code docutils literal notranslate"><span class="pre">"key$":["SQL</span> <span class="pre">search</span> <span class="pre">expressions"]</span></code></p><p>Any SQL search expression can be applied here.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:3,%22User%22:%7B%22name$%22:%22%2525m%2525%22%7D%7D%7D">"name$":"%m%"</a></p><p>In SQL, it’s <code class="code docutils literal notranslate"><span class="pre">name</span> <span class="pre">LIKE</span> <span class="pre">'%m%'</span></code>, meaning that get <em>User</em> with ‘m’ in name.</p></div></blockquote></div><hr class="docutils" /><p><strong>Regular Expression</strong> <code class="code docutils literal notranslate"><span class="pre">"key~":"regular</span> <span class="pre">expression"</span></code> => <code class="code docutils literal notranslate"><span class="pre">"key~":["regular</span> <span class="pre">expression"]</span></code></p><p>It can be any regular expressions. Advanced search is applicable.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:3,%22User%22:%7B%22name~%22:%22%5E%5B0-9%5D%252B$%22%7D%7D%7D">"name~":"^[0-9]+$"</a></p><p>In SQL, it’s <code class="code docutils literal notranslate"><span class="pre">name</span> <span class="pre">REGEXP</span> <span class="pre">'^[0-9]+$'</span></code>.</p></div></blockquote></div><hr class="docutils" /><p><strong>Get data in a range</strong> <code class="code docutils literal notranslate"><span class="pre">"key%":"start,end"</span></code> => <code class="code docutils literal notranslate"><span class="pre">"key%":["start,end"]</span></code></p><p>The data type of start and end can only be either <strong>Boolean</strong>, <strong>Number</strong> or <strong>String</strong>. Eg. "2017年01月01日,2019年01月01日", ["1,90000", "82001,100000"]. It’s used for getting data from a specific time range.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:3,%22User%22:%7B%22date%2525%22:%222017-10-01,2018年10月01日%22%7D%7D%7D">"date%":"2017年10月01日,2018年10月01日"</a></p><blockquote><div><p>In SQL, it’s <code class="code docutils literal notranslate"><span class="pre">date</span> <span class="pre">BETWEEN</span> <span class="pre">'2017-10-01'</span> <span class="pre">AND</span> <span class="pre">'2018-10-01'</span></code>, meaning to get <em>User</em> data that registered between 2017年10月01日 and 2018年10月01日.</p></div></blockquote></div></blockquote></div><hr class="docutils" /><p><strong>Make an alias</strong> <code class="code docutils literal notranslate"><span class="pre">"name:alias"</span></code></p><p>This changes name to alias in returning results. It’s applicable to column, tableName, SQL Functions, etc. but only in GET, HEAD requests.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22Comment%22:%7B%22@column%22:%22id,toId:parentId%22,%22id%22:51%7D%7D">/get/{"Comment":{"@column":"id,toId:parentId","id":51}}</a></p><p>In SQL, it’s <code class="code docutils literal notranslate"><span class="pre">toId</span> <span class="pre">AS</span> <span class="pre">parentId</span></code>. It’ll return <em>parentID</em> instead of <em>toID</em>.</p></div></blockquote></div><hr class="docutils" /><p><strong>Add / expand an item</strong> <code class="code docutils literal notranslate"><span class="pre">"key+":number/string/array...</span></code></p><p>The type of value on the right of the colon is decided by key. Types can be <strong>Number</strong> (such as 82001), <strong>String</strong> (such as "url0"), <strong>JSONArray</strong> (such as ["url0","url1"]). The method can only be <strong>PUT</strong>.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><dl class="field-list simple"><dt class="field-odd">code</dt><dd class="field-odd"><p><cite>"praiseUserIdList+":[82001]</cite></p></dd></dl><p>In this example, add id 82001 to the praiser’s list. In SQL, it should be <code class="code docutils literal notranslate"><span class="pre">json_insert(praiseUserIdList,82001)</span></code>.</p></div></blockquote></div><hr class="docutils" /><p><strong>Delete / decrease an item</strong> <code class="code docutils literal notranslate"><span class="pre">"Key-":number/string/array...</span></code></p><p>It has the contrary function of <code class="code docutils literal notranslate"><span class="pre">"key+"</span></code>.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><code class="code docutils literal notranslate"><span class="pre">"balance-":100.00</span></code></p><p>This example subtract 100 in the balance. In SQL, it would be <code class="code docutils literal notranslate"><span class="pre">balance</span> <span class="pre">=</span> <span class="pre">balance</span> <span class="pre">-</span> <span class="pre">100.00</span></code>.</p></div></blockquote></div><hr class="docutils" /><p><strong>Logical Operators</strong> <code class="code docutils literal notranslate"><span class="pre">&,|,!</span></code></p><p><code class="code docutils literal notranslate"><span class="pre">&,|,!</span></code> refer to <strong>AND</strong>, <strong>OR</strong>, <strong>NOT</strong> in SQL respectively. The basic form to use them are: <code class="code docutils literal notranslate"><span class="pre">"key&{}":"conditions"</span></code>, <code class="code docutils literal notranslate"><span class="pre">"key|{}":"conditions"</span></code>, <code class="code docutils literal notranslate"><span class="pre">"key!{}":Object</span></code>.</p><p>By default, conditions of the same key are connected with <code class="code docutils literal notranslate"><span class="pre">|</span></code> operator. As for different <code class="code docutils literal notranslate"><span class="pre">"key":"conditons"`pairs,</span> <span class="pre">the</span> <span class="pre">default</span> <span class="pre">operator</span> <span class="pre">among</span> <span class="pre">them</span> <span class="pre">is</span> <span class="pre">:code:`&</span></code>.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p>1 <a class="reference external" href="http://apijson.cn:8080/head/%7B%22User%22:%7B%22id&%7B%7D%22:%22%3E80000,%3C=90000%22%7D%7D">/head/{"User":{"id&{}":">80000,<=90000"}}</a></p><p>In SQL, it’s <code class="code docutils literal notranslate"><span class="pre">id>80000</span> <span class="pre">AND</span> <span class="pre">id<=90000</span></code>, meaning id needs to be <code class="code docutils literal notranslate"><span class="pre">id>80000</span> <span class="pre">&</span> <span class="pre">id<=90000</span></code></p><p>2 <a class="reference external" href="http://apijson.cn:8080/head/%7B%22User%22:%7B%22id%7C%7B%7D%22:%22%3E90000,%3C=80000%22%7D%7D">/head/{"User":{"id|{}":">90000,<=80000"}}</a>.</p><p>It’s the same as <code class="code docutils literal notranslate"><span class="pre">"id{}":">90000,<=80000"</span></code>. In SQL, it’s <code class="code docutils literal notranslate"><span class="pre">id>80000</span> <span class="pre">OR</span> <span class="pre">id<=90000</span></code>, meaning that id needs to be <code class="code docutils literal notranslate"><span class="pre">id>90000</span> <span class="pre">|</span> <span class="pre">id<=80000</span></code>.</p><p>3 <a class="reference external" href="http://apijson.cn:8080/head/%7B%22User%22:%7B%22id!%7B%7D%22:%5B82001,38710%5D%7D%7D">/head/{"User":{"id!{}":[82001,38710]}}</a>.</p><p>In SQL, it’s <code class="code docutils literal notranslate"><span class="pre">id</span> <span class="pre">NOT</span> <span class="pre">IN(82001,38710)</span></code>, meaning <code class="code docutils literal notranslate"><span class="pre">id</span></code> needs to be <code class="code docutils literal notranslate"><span class="pre">!</span> <span class="pre">(id=82001</span> <span class="pre">|</span> <span class="pre">id=38710)</span></code>.</p></div></blockquote></div></div><hr class="docutils" /><div class="section" id="build-in-string-functions-part-one"><h2>3. Build-in string functions part one<a class="headerlink" href="#build-in-string-functions-part-one" title="Permalink to this headline">¶</a></h2><p>1 <code class="code docutils literal notranslate"><span class="pre">"count":Integer</span></code></p><p>This is used to set the maximum number of the returning resources. The maximum number the system supports is 100. Without this, it’ll return the maximum number of results that meet the condition.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22%5B%5D%22:%7B%22count%22:5,%22User%22:%7B%7D%7D%7D">/get/{"[]":{"count":5,"User":{}}}</a></p><p>This example requests 5 Users’ data.</p></div></blockquote></div><hr class="docutils" /><p>2 <code class="code docutils literal notranslate"><span class="pre">"page":Integer</span></code></p><p>This is to indicate the page number starting with 0. The max number can be 100. It’s usually used with <code class="code docutils literal notranslate"><span class="pre">"count":Integer</span></code></p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22%5B%5D%22:%7B%22count%22:5,%22page%22:3,%22User%22:%7B%7D%7D%7D">/get/{"[]":{"count":5,"page":3,"User":{}}}</a></p><p>This example get Users data on page 3 with the total number of 5.</p></div></blockquote></div><hr class="docutils" /><p>3 <code class="code docutils literal notranslate"><span class="pre">"query":Integer</span></code></p><p>When the <code class="code docutils literal notranslate"><span class="pre">Integer</span></code> is 0, it means get the resource. When it’s 1, it means counting the number and returning the number.When it’s 2, it means returning both.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22%5B%5D%22:%7B%22query%22:2,%22count%22:5,%22User%22:%7B%7D%7D,%22total@%22:%22%252F%5B%5D%252Ftotal%22%7D">/get/{"[]":{"query":2, User:{}}, "total@":"/[]/total"}</a></p></div></blockquote></div><hr class="docutils" /><p>4 <code class="code docutils literal notranslate"><span class="pre">"join":"&/Table0/key0@,</Table1/key1@"</span></code></p><p>The joining table functions are represented by symbols:</p><p>"<" - LEFT JOIN</p><p>">" - RIGHT JOIN</p><p>"&" - INNER JOIN</p><p>"|" - FULL JOIN</p><p>"!" - OUTTER JOIN</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22%5B%5D%22:%7B%22count%22:5,%22join%22:%22&%252FUser%252Fid@,%3C%252FComment%252FmomentId@%22,%22Moment%22:%7B%22@column%22:%22id,userId,content%22%7D,%22User%22:%7B%22name%253F%22:%22t%22,%22id@%22:%22%252FMoment%252FuserId%22,%22@column%22:%22id,name,head%22%7D,%22Comment%22:%7B%22momentId@%22:%22%252FMoment%252Fid%22,%22@column%22:%22id,momentId,content%22%7D%7D%7D">/get/{"[]":{"join": "&/User/id@,</Comment/momentId@", "Moment":{}, "User":{"name?":"t", "id@": "/Moment/userId"}, "Comment":{"momentId@": "/Moment/id"}}}</a></p></div></blockquote><p>This examples is equal to SQL expression <code class="code docutils literal notranslate"><span class="pre">Moment</span> <span class="pre">INNER</span> <span class="pre">JOIN</span> <span class="pre">User</span> <span class="pre">LEFT</span> <span class="pre">JOIN</span> <span class="pre">Comment</span></code>.</p></div></blockquote></div></div><hr class="docutils" /><div class="section" id="build-in-string-functions-part-two"><h2>4. Build-in string functions part two<a class="headerlink" href="#build-in-string-functions-part-two" title="Permalink to this headline">¶</a></h2><p>1 <code class="code docutils literal notranslate"><span class="pre">"@combine":"&key0,&key1,|key2,key3,!key4,!key5,&key6,key7..."</span></code></p><p>This function combines conditions that have been listed to request data. It’ll group conditions according to their types. It uses logical operators(&,|,!) to connect among groups while within a group, it’ll follow the order that conditions have been listed. So, it’ll become :code:<a href="#id7"><span class="problematic" id="id8">`</span></a>(key0 & key1 & key6 & other keys) & (key2 | key3 | key7) & !(key4 | key5) `</p><p>The:code:<cite>other keys</cite> means keys that aren’t included in <code class="code docutils literal notranslate"><span class="pre">combine</span></code> function. By default, it’s connected by AND.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:10,%22User%22:%7B%22@column%22:%22id,name,tag%22,%22name~%22:%22a%22,%22tag~%22:%22a%22,%22@combine%22:%22name~,tag~%22%7D%7D%7D">/get/{"User[]":{"count":10,"User":{"@column":"id,name,tag","name~":"a","tag~":"a","@combine":"name~,tag~"}}}</a></p><p>This example request User objects whose <code class="code docutils literal notranslate"><span class="pre">name</span></code> or <code class="code docutils literal notranslate"><span class="pre">tag</span></code> includes "a".</p></div></blockquote></div><hr class="docutils" /><p>2 <code class="code docutils literal notranslate"><span class="pre">"@column":"column;function(arg)..."</span></code></p><p>This function defines which colunms will be returned.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%22:%7B%22@column%22:%22id,sex,name%22,%22id%22:38710%7D%7D">/get/{"User":{"@column":"id,sex,name","id":38710}}</a></p><p>This request only returns colunms: id, sex, name. The returning follows the same order.</p></div></blockquote></div><hr class="docutils" /><p>3 <code class="code docutils literal notranslate"><span class="pre">"@order":"column0+,column1-..."</span></code></p><p>This function can set descendent or ascendent order of returning data within a column.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22%5B%5D%22:%7B%22count%22:10,%22User%22:%7B%22@column%22:%22name,id%22,%22@order%22:%22name-,id%22%7D%7D%7D">/get/{"[]":{"count":10,"User":{"@column":"name,id","@order":"name-,id"}}}</a></p><p>This example requests data following descendent order in name column while the default order in id column.</p></div></blockquote></div><hr class="docutils" /><p>4 <code class="code docutils literal notranslate"><span class="pre">"@group":"column0,column1..."</span></code></p><p>This function groups data with columns. If the table’s <code class="code docutils literal notranslate"><span class="pre">id</span></code> has been declared in <code class="code docutils literal notranslate"><span class="pre">@column</span></code>, then the <code class="code docutils literal notranslate"><span class="pre">id</span></code> needs to be included in <code class="code docutils literal notranslate"><span class="pre">@group</span></code>.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22%5B%5D%22:%7B%22count%22:10,%22Moment%22:%7B%22@column%22:%22userId,id%22,%22@group%22:%22userId,id%22%7D%7D%7D">/get/{"[]":{"count":10,"Moment":{"@column":"userId,id","@group":"userId,id"}}}</a></p><p>This example returns <code class="code docutils literal notranslate"><span class="pre">id</span></code> grouped by userId.</p></div></blockquote></div><hr class="docutils" /><p>5 <code class="code docutils literal notranslate"><span class="pre">"@having":"function0(...)?value0;function1(...)?value1;function2(...)?value2..."</span></code></p><p>This function is as same as the <strong>HAVING</strong> function in AQL. Normally, it’s used with <code class="code docutils literal notranslate"><span class="pre">@group</span></code>.</p><div class="toggle-header docutils container"><p>Example</p></div><div class="toggle-content docutils container"><blockquote><div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22%5B%5D%22:%7B%22count%22:10,%22Moment%22:%7B%22@column%22:%22userId%253Bmax(id)%22,%22@group%22:%22userId%22,%22@having%22:%22max(id)%3E=100%22%7D%7D%7D">/get/{"[]":{"Moment":{"@column":"userId;max(id)","@group":"userId","@having":"max(id)>=100"}}}</a></p><p>This example get an array of Moment with userID and id where id >=100, grouped by userId.</p></div></blockquote></div><hr class="docutils" /><p>6 <code class="code docutils literal notranslate"><span class="pre">"@schema":"sys"</span></code></p></div></div></div></div><footer><div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"><a href="why.html" class="btn btn-neutral float-right" title="How does APIJSON works?" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a><a href="../quick_start/client_deployment/client_deployment.html" class="btn btn-neutral float-left" title="Client-side Deployment" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a></div><hr/><div role="contentinfo"><p>© Copyright 2019, Ruoran Wang</p></div>Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.</footer></div></div></section></div><script type="text/javascript">jQuery(function () {SphinxRtdTheme.Navigation.enable(true);});</script></body></html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。