UNPKG

json-odm

Version:

Object document mapper for JSON data that provides mongodb methods for querying and transformation as well as additional joining that is not provided by mongodb. >> IF YOU LIKE IT, PLEASE GIVE IT A STAR ON GITHUB <<

1,379 lines (468 loc) 17.1 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>Documentation Class: Util</title> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/sunlight.default.css"> <link type="text/css" rel="stylesheet" href="styles/site.cerulean.css"> </head> <body> <div class="navbar navbar-default navbar-fixed-top "> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="index.html">Documentation</a> <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <div class="navbar-collapse collapse" id="topNavigation"> <ul class="nav navbar-nav"> <li class="dropdown"> <a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a> <ul class="dropdown-menu "> <li><a href="JsonOdm.html">JsonOdm</a></li><li><a href="jsonOdm.Collection.html">jsonOdm.Collection</a></li><li><a href="jsonOdm.Geo.html">jsonOdm.Geo</a></li><li><a href="jsonOdm.Geo.BoundaryBox.html">jsonOdm.Geo.BoundaryBox</a></li><li><a href="jsonOdm.Geo.Feature.html">jsonOdm.Geo.Feature</a></li><li><a href="jsonOdm.Geo.FeatureCollection.html">jsonOdm.Geo.FeatureCollection</a></li><li><a href="jsonOdm.Geo.GeometryCollection.html">jsonOdm.Geo.GeometryCollection</a></li><li><a href="jsonOdm.Geo.LineString.html">jsonOdm.Geo.LineString</a></li><li><a href="jsonOdm.Geo.MultiLineString.html">jsonOdm.Geo.MultiLineString</a></li><li><a href="jsonOdm.Geo.MultiPoint.html">jsonOdm.Geo.MultiPoint</a></li><li><a href="jsonOdm.Geo.MultiPolygon.html">jsonOdm.Geo.MultiPolygon</a></li><li><a href="jsonOdm.Geo.Point.html">jsonOdm.Geo.Point</a></li><li><a href="jsonOdm.Geo.Polygon.html">jsonOdm.Geo.Polygon</a></li><li><a href="jsonOdm.Query.html">jsonOdm.Query</a></li><li><a href="jsonOdm.Util.html">jsonOdm.Util</a></li> </ul> </li> </ul> <div class="col-sm-3 col-md-3"> <form class="navbar-form" role="search"> <div class="input-group"> <input type="text" class="form-control" placeholder="Search" name="q" id="search-input"> <div class="input-group-btn"> <button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button> </div> </div> </form> </div> </div> </div> </div> <div class="container" id="toc-content"> <div class="row"> <div class="col-md-8"> <div id="main"> <h1 class="page-title">Class: Util</h1> <section> <header> <h2> Util </h2> </header> <article> <div class="container-overview"> <hr> <dt> <h4 class="name" id="Util"><span class="type-signature"></span>new Util()</h4> </dt> <dd> <div class="description"> <p>The Utility Class that provides some useful methods used throughout the ODM</p> </div> <dl class="details"> </dl> </dd> </div> <h3 class="subsection-title">Methods</h3> <dl> <hr> <dt> <h4 class="name" id="branch"><span class="type-signature"></span>branch(object, path)</h4> </dt> <dd> <div class="description"> <p>Query an object with a function</p> </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>object</code></td> <td class="type"> <span class="param-type">Object</span> | <span class="param-type">Array</span> </td> <td class="attributes"> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>path</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> &lt;repeatable><br> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> </dd> <hr> <dt> <h4 class="name" id="is"><span class="type-signature"></span>is(object, type)</h4> </dt> <dd> <div class="description"> <p>Checks the type of an object. valid type values are: number, string, undefined, object, array and RegExp, ArrayBuffer, null, boolean plus all other [object *] types</p> </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>object</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="description last"><p>The object to test against a type</p></td> </tr> <tr> <td class="name"><code>type</code></td> <td class="type"> <span class="param-type">string</span> | <span class="param-type">Array.&lt;string></span> </td> <td class="description last"><p>All possible types that will result in a true</p></td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> </dd> <hr> <dt> <h4 class="name" id="isArray"><span class="type-signature"></span>isArray(arrayObject)</h4> </dt> <dd> <div class="description"> <p>Checks the input parameter and returns true if it is an array</p> </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>arrayObject</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> </dd> <hr> <dt> <h4 class="name" id="objectKeys"><span class="type-signature"></span>objectKeys(object)</h4> </dt> <dd> <div class="description"> <p>Get only the keys of an object</p> </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>object</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last"><p>The objects to get the keys from</p></td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>An array of keys</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> </dd> <hr> <dt> <h4 class="name" id="objectKeysPolyfill"><span class="type-signature"></span>objectKeysPolyfill(object)</h4> </dt> <dd> <div class="description"> <p>Polyfill for Object.keys</p> </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>object</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last"><p>The objects to get the keys from</p></td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>An array of keys</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> </dd> <hr> <dt> <h4 class="name" id="projectElement"><span class="type-signature"></span>projectElement(projection, element [, parentElement])</h4> </dt> <dd> <div class="description"> <p>Projects an element to a projectionDefinition</p> </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>projection</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="attributes"> </td> <td class="description last"><p>The projection definition object</p></td> </tr> <tr> <td class="name"><code>element</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="attributes"> </td> <td class="description last"><p>The element that is projected from</p></td> </tr> <tr> <td class="name"><code>parentElement</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last"><p>for internal recursion purpose</p></td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>The projected element</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">object</span> </dd> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">jsonOdm.util.projectElement({ key1:&#x27;value1&#x27;, key2:&#x27;value2&#x27; },{ key1:1, key12:function(element){return element.key1 + element.key2} // only field modifying queries are allowed key2:collection.$query.$branch(&quot;key2&quot;).$substr(0,3) }) // will return {key1:&#x27;value1&#x27;,key12:&#x27;value1value2&#x27;,key2:&#x27;val&#x27;}</pre> </dd> </dl> </article> </section> </div> </div> <div class="clearfix"></div> <div class="col-md-3"> <div id="toc" class="col-md-3 hidden-xs hidden-sm hidden-md"></div> </div> </div> </div> <div class="modal fade" id="searchResults"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title">Search results</h4> </div> <div class="modal-body"></div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div> <footer> <span class="jsdoc-message"> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on July 15th 2016, 4:15:54 pm using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>. </span> </footer> <script src="scripts/docstrap.lib.js"></script> <script src="scripts/toc.js"></script> <script type="text/javascript" src="scripts/fulltext-search-ui.js"></script> <script> $( function () { $( "[id*='$']" ).each( function () { var $this = $( this ); $this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) ); } ); $( ".tutorial-section pre, .readme-section pre" ).each( function () { var $this = $( this ); var example = $this.find( "code" ); exampleText = example.html(); var lang = /{@lang (.*?)}/.exec( exampleText ); if ( lang && lang[1] ) { exampleText = exampleText.replace( lang[0], "" ); example.html( exampleText ); lang = lang[1]; } else { var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/); lang = langClassMatch ? langClassMatch[1] : "javascript"; } if ( lang ) { $this .addClass( "sunlight-highlight-" + lang ) .addClass( "linenums" ) .html( example.html() ); } } ); Sunlight.highlightAll( { lineNumbers : true, showMenu : true, enableDoclinks : true } ); $.catchAnchorLinks( { navbarOffset: 10 } ); $( "#toc" ).toc( { anchorName : function ( i, heading, prefix ) { var id = $( heading ).attr( "id" ); return id && id.replace(/\~/g, '-inner-').replace(/\./g, '-static-') || ( prefix + i ); }, selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4", showAndHide : false, smoothScrolling: true } ); $( "#main span[id^='toc']" ).addClass( "toc-shim" ); $( '.dropdown-toggle' ).dropdown(); $( "table" ).each( function () { var $this = $( this ); $this.addClass('table'); } ); } ); </script> <!--Navigation and Symbol Display--> <!--Google Analytics--> <script type="text/javascript"> $(document).ready(function() { SearcherDisplay.init(); }); </script> </body> </html>