new Controller(resources)
A core constructor that provides numerous controller helper functions.
Parameters:
| Name | Type | Description |
|---|---|---|
resources |
object | variable injection from resources from instantiated periodic express app |
- Copyright:
- Copyright (c) 2014 Typesettin. All rights reserved.
- License:
- MIT
- Source:
Requires
- module:fs-extra
- module:path
- module:periodicjs.core.utilities
Methods
-
createModel(options) → {object}
-
short hand mongoose create document query
Parameters:
Name Type Description optionsobject model,newdoc - document to insert, req, res,callback, successredirect, appendid - append the id of newly created document on redirect
- Source:
Returns:
responseData or redirected page
- Type
- object
-
deleteModel(options) → {function}
-
short hand mongoose delete document query
Parameters:
Name Type Description optionsobject model,deleteid - id to delete,callback
- Source:
Returns:
callback(err)
- Type
- function
-
getPluginViewDefaultTemplate(options, callback) → {function}
-
Gets the path to the view file specified, first look at custom theme views, then extension views, then default views
Parameters:
Name Type Description optionsobject extname, themename, themefileext - support custom theme files
callbackfunction async callback
- Source:
Returns:
async callback(err,viewname)
- Type
- function
-
handleDocumentQueryErrorResponse(options) → {object}
-
default response handler for error, or will redirect with flash error set
Parameters:
Name Type Description optionsobject err,req,res,callback
- Source:
Returns:
response object render or callback
- Type
- object
-
handleDocumentQueryRender(options) → {object}
-
default response handler for express views, or will redirect to another request
Parameters:
Name Type Description optionsobject 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
- Source:
Returns:
response object render or callback
- Type
- object
-
loadModel(options) → {function}
-
short hand mongoose load document query
Parameters:
Name Type Description optionsobject model,docid - id or name,callback,population -mongoose population, selection - mongoose selection
- Source:
Returns:
callback(err,document)
- Type
- function
-
searchModel(options) → {function}
-
short hand mongoose search documents query
Parameters:
Name Type Description optionsobject model,query - mongoose query,callback,population -mongoose population, selection - mongoose selection , limit, offset
- Source:
Returns:
callback(err,documents)
- Type
- function
-
updateModel(options) → {object}
-
short hand mongoose update document query
Parameters:
Name Type Description optionsobject 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
- Source:
Returns:
responseData or redirected page
- Type
- object