Class: ModelAPIRouter

ModelAPIRouter

ModelAPIRouter - express router dispatches REST-calls to api-controllers

Constructor

new ModelAPIRouter(model, optionsopt) → {ModelAPIRouter}

Parameters:
Name Type Attributes Description
model mongoose.Model | String model to be exposed
options Object <optional>
router configuration object
Properties
Name Type Attributes Description
options Object | Boolean <optional>
options for OPTIONS http-method
create Object | Boolean <optional>
options for CREATE REST-method
search Object | Boolean <optional>
options for SEARCH(LIST) REST-method
details Object | Boolean <optional>
options for DETAILS REST-method
update Object | Boolean <optional>
options for UPDATE REST-method
delete Object | Boolean <optional>
options for DELETE REST-method
expose Object | Boolean <optional>
options for exposing methods of model
exposeStatic Object | Boolean <optional>
options for exposing static model methods
path String <optional>
the path to mount router (levels: router|METHOD)
filter Object | function <optional>
the mongodb-filter object or function that returns the same type object (levels: router|METHOD)
fields Object <optional>
the mongodb-fields descriptor (levels: router|METHOD)
queryFields Object <optional>
the object with keys that defines allow to use field in query or not
popuplate String | Object | Array <optional>
the mongoose population descriptor (levels: router|METHOD)
skip Boolean <optional>
the flag to allow or deny skipping documents (levels: router|METHOD)
limit Boolean <optional>
the flag to allow or deny limit documents number (levels: router|METHOD)
sort Object | Boolean <optional>
the flag or an object that defines fields to be used for documents corting (levels: router|METHOD)
middlewares function | Array <optional>
the Function or Array of Function that should be called before the router controller will be called (levels: router|METHOD)
matchId String | RegExp <optional>
the String or RegExp that allows to identify values of _id to build correct routing paths
title String <optional>
the short description of the path
Source:
Returns:
created router
Type
ModelAPIRouter

Methods

attachTo(app) → {ModelAPIRouter}

ModelAPIRouter.prototype.attachTo - attaches the router to the ModelAPIExpress
Parameters:
Name Type Description
app ModelAPIExpress the API Application to which the router should be mounted
Source:
Returns:
self
Type
ModelAPIRouter

urls(rootPath) → {Array}

ModelAPIRouter.prototype.urls - returns avaliable urls
Parameters:
Name Type Description
rootPath String the path to the router (before it)
Source:
Returns:
the list of avaliable urls
Type
Array