<div style="width: 401px" class="wp-caption aligncenter"><a href="https://nodei.co/npm/node-json-db/"><img class="" src="https://nodei.co/npm/node-json-db.png?downloads=true&;stars=true" alt="JsonDbStats" width="391" height="69" /></a><p class="wp-caption-text">JsonDb Stats</p></div>
[github-issue username=&#8221;belphemur&#8221; repository=&#8221;node-json-db&#8221; number=&#8221;11&#8243;]
<p>I never thought of it, but supporting an append semantic in the &#8220;jsonLanguage&#8221; I created is an excellent idea. After all this semantic (array[]) is already used in other languages like PHP, why not implementing it here also.</p>
<p>From the version 0.6.0 Node-Json-DB support this new semantic to append an element to an array:</p>
<pre class="brush: jscript; title: ; notranslate" title=""> 
//You can also easily append new item to an existing array 
//This set the next index with {obj: 'test'} 
db.push(";/arraytest/myarray&#x5B;]";, {obj:'test'}, true); 
 
 
//The append feature can be used in conjuction with properties 
//This will set the next index as an object {myTest: 'test'} 
db.push(";/arraytest/myarray&#x5B;]/myTest";, 'test', true); 
</pre>
<p>I&#8217;m thinking of adding more semantic support to the array like a possibility to get the last item with &#8220;array[-1]&#8221; etc &#8230;<br />
I also found documentation on <a href="http://goessner.net/articles/JsonPath/">JsonPath</a>. I&#8217;m thinking of implementing some of it in a new method <em>path.</em> It would be only used for querying the data, not for pushing it. Or maybe the support will be included directly into the existing method. I still have to think about it and if it wouldn&#8217;t make this small library too big.</p>

Leave a Reply Cancel reply