UNPKG

periodicjs.core.controller

Version:
1,360 lines (458 loc) 18.3 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: Controller</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Class: Controller</h1> <section> <header> <h2> Controller </h2> </header> <article> <div class="container-overview"> <dt> <h4 class="name" id="Controller"><span class="type-signature"></span>new Controller<span class="signature">(resources)</span><span class="type-signature"></span></h4> </dt> <dd> <div class="description"> <p>A core constructor that provides numerous controller helper functions.</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>resources</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"><p>variable injection from resources from instantiated periodic express app</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-author">Author:</dt> <dd class="tag-author"> <ul> <li>Yaw Joseph Etse</li> </ul> </dd> <dt class="tag-copyright">Copyright:</dt> <dd class="tag-copyright"><ul class="dummy"><li>Copyright (c) 2014 Typesettin. All rights reserved.</li></ul></dd> <dt class="tag-license">License:</dt> <dd class="tag-license"><ul class="dummy"><li>MIT</li></ul></dd> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="controller.js.html">controller.js</a>, <a href="controller.js.html#line30">line 30</a> </li></ul></dd> </dl> </dd> </div> <h3 class="subsection-title">Requires</h3> <ul> <li>module:fs-extra</li> <li>module:path</li> <li>module:periodicjs.core.utilities</li> </ul> <h3 class="subsection-title">Methods</h3> <dl> <dt> <h4 class="name" id="createModel"><span class="type-signature"></span>createModel<span class="signature">(options)</span><span class="type-signature"> &rarr; {object}</span></h4> </dt> <dd> <div class="description"> <p>short hand mongoose create document query</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"><p>model,newdoc - document to insert, req, res,callback, successredirect, appendid - append the id of newly created document on redirect</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="controller.js.html">controller.js</a>, <a href="controller.js.html#line515">line 515</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>responseData or redirected page</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">object</span> </dd> </dl> </dd> <dt> <h4 class="name" id="deleteModel"><span class="type-signature"></span>deleteModel<span class="signature">(options)</span><span class="type-signature"> &rarr; {function}</span></h4> </dt> <dd> <div class="description"> <p>short hand mongoose delete document query</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"><p>model,deleteid - id to delete,callback</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="controller.js.html">controller.js</a>, <a href="controller.js.html#line898">line 898</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>callback(err)</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">function</span> </dd> </dl> </dd> <dt> <h4 class="name" id="getPluginViewDefaultTemplate"><span class="type-signature"></span>getPluginViewDefaultTemplate<span class="signature">(options, callback)</span><span class="type-signature"> &rarr; {function}</span></h4> </dt> <dd> <div class="description"> <p>Gets the path to the view file specified, first look at custom theme views, then extension views, then default views</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"><p>extname, themename, themefileext - support custom theme files</p></td> </tr> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last"><p>async callback</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="controller.js.html">controller.js</a>, <a href="controller.js.html#line46">line 46</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>async callback(err,viewname)</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">function</span> </dd> </dl> </dd> <dt> <h4 class="name" id="handleDocumentQueryErrorResponse"><span class="type-signature"></span>handleDocumentQueryErrorResponse<span class="signature">(options)</span><span class="type-signature"> &rarr; {object}</span></h4> </dt> <dd> <div class="description"> <p>default response handler for error, or will redirect with flash error set</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"><p>err,req,res,callback</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="controller.js.html">controller.js</a>, <a href="controller.js.html#line272">line 272</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>response object render or callback</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">object</span> </dd> </dl> </dd> <dt> <h4 class="name" id="handleDocumentQueryRender"><span class="type-signature"></span>handleDocumentQueryRender<span class="signature">(options)</span><span class="type-signature"> &rarr; {object}</span></h4> </dt> <dd> <div class="description"> <p>default response handler for express views, or will redirect to another request</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"><p>res,req,redirecturl,err,callback,responseData - this is what's sent to the rendered template view, also appends http request information like base url, query string parameters, etc</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="controller.js.html">controller.js</a>, <a href="controller.js.html#line116">line 116</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>response object render or callback</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">object</span> </dd> </dl> </dd> <dt> <h4 class="name" id="loadModel"><span class="type-signature"></span>loadModel<span class="signature">(options)</span><span class="type-signature"> &rarr; {function}</span></h4> </dt> <dd> <div class="description"> <p>short hand mongoose load document query</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"><p>model,docid - id or name,callback,population -mongoose population, selection - mongoose selection</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="controller.js.html">controller.js</a>, <a href="controller.js.html#line341">line 341</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>callback(err,document)</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">function</span> </dd> </dl> </dd> <dt> <h4 class="name" id="searchModel"><span class="type-signature"></span>searchModel<span class="signature">(options)</span><span class="type-signature"> &rarr; {function}</span></h4> </dt> <dd> <div class="description"> <p>short hand mongoose search documents query</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"><p>model,query - mongoose query,callback,population -mongoose population, selection - mongoose selection , limit, offset</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="controller.js.html">controller.js</a>, <a href="controller.js.html#line438">line 438</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>callback(err,documents)</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">function</span> </dd> </dl> </dd> <dt> <h4 class="name" id="updateModel"><span class="type-signature"></span>updateModel<span class="signature">(options)</span><span class="type-signature"> &rarr; {object}</span></h4> </dt> <dd> <div class="description"> <p>short hand mongoose update document query</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"><p>model, id - objectid of mongoose document,updatedoc - document to update, req, res,callback, successredirect, appendid - append the id of newly created document on redirect, removefromarray - sets the update operation to manipulate an array of documents with mongo $pull, appendArray - sets the update operation to manipulate an array of documents with mongo $push, saverevision - save revisions</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="controller.js.html">controller.js</a>, <a href="controller.js.html#line713">line 713</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>responseData or redirected page</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">object</span> </dd> </dl> </dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Controller.html">Controller</a></li></ul> </nav> <br clear="both"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Fri Jan 30 2015 17:57:38 GMT-0500 (EST) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>