Model methods
As pointed above the router level has two parameters that allow to call model methods through the api. These parameters are:
- expose:
Object
- configuration for end-points that expose the instance methods defined on its schema - exposeStatic:
Object
- configuration for end-points that expose static model methods defined on its schema.
The keys of these paramters are the names of the Model methods (instance or static).
The each value of the key could be on of types: Boolean
|String
|Object
{
expose: {
methodName: `Boolean` | `String` | `Object`,
methodName: `Boolean` | `String` | `Object`
...
},
exposeStatic: {
methodName: `String` | `Object`,
...
}
}
In case of Boolean
the value means if method-end-point is allowed (true
) or is disabled (false
).
There is a special key "*"
that allows to enable or to disable all methods together.
{
expose: {'*': true} // all instance method will be exposed
}
In case of String
merest mounts controller that calls correspondent method to the HTTP-method specified by value (if value is on of Express-supported HTTP-methods).
Otherwise (the value is not a HTTP-method) merest mounts appropriate controller to POST (or other method specified directly) and adds created method-end-point to list with value as description.
In case of Object
merest uses the value to configure method-end-point with the following parameters:
- method:
String
- the HTTP method to mount method-end-point (if omitted the method-controller will be mount on the POST) - path:
String
- theadditional-path
to mount method-controller - exec:
Function
- the Function that will be called instead of Model instance/static method with context of Document or the Model. You could to call any Model method from this function usingthis
. - middlewares:
Function|Array
- middleware function or array of such functions. The middleware(s) will be mounted to the method-end-point route as usual express middleware - title:
String
- the description of the end-point
Signature of Model method that can be exposed
The controller that calls certain Model method passes to the one two parameters:
- params:
Object
- parameters sent from client (in the Query String or in Request Body dependent on the HTTP method used to mount method-end-point) - callback:
Function
- Function that should be called after method processed.
/**
* @param {Object} params
* @param {Function} callback
* @return {undefined}
*/
modelSchema.methods.methodName = function (params, callback) {
// this -- referencies the document instance
}
and the static method with the same:
/**
* @param {Object} params
* @param {Function} callback
* @return {undefined}
*/
modelSchema.statics.methodName = function (params, callback) {
// this -- referencies the model
}
Signature of callback-function:
/**
* @param {Error} err exception raised in the method call
* @param {Object|Array|String} dataToReturn The data to be return in Response Body
*/
function callback(err, dataToReturn) {
...
}
For example:
VectorSchema.methods.reverse = function(params, callback) {
this.x = -this.x;
this.y = -this.y;
return this.save(callback);
}
or in case of statics
:
VectorSchema.statics.reverse = function(params, callback) {
var self = this;
self.update(params, {$mul: {x:-1, y:-1} }, {multi: true}, function (err) {
if (err) return done(err);
return self.find(callback);
});
}
Exposing the methods
var api = new merest.ModelAPIExpress();
api.expose(models.Vector, { // Model-routes level
fields: 'x y',
expose: { reverse: 'get' },
exposeStatic: { reverse: 'get' }
});
Getting the vector details:
curl -g http://localhost:1337/api/v1/vectors/573f19d35b54089f3993605f/
Output:
{"_id": "573f19d35b54089f3993605f", "x": 1, "y": 2}
Calling method-end-point:
curl -g http://localhost:1337/api/v1/vectors/573f19d35b54089f3993605f/reverse
Output:
{"__v": 1, "_id": "573f19d35b54089f3993605f", "x": -1, "y": -2}
Getting the vector details again:
curl -g http://localhost:1337/api/v1/vectors/573f19d35b54089f3993605f/
Output:
{"_id": "573f19d35b54089f3993605f", "x": -1, "y": -2}
Calling the static method:
curl -g http://localhost:1337/api/v1/vectors/reverse
Output:
[
{"_id": "...", "x": -1, "y": -2},
{"_id": "...", "x": 0, "y": -3}
]
And after that calling againg with parameters
curl -g http://localhost:1337/api/v1/vectors/reverse?x=0
Output:
[
{"_id": "...", "x": 0, "y": 3}
]
Lookout the merest doesn't clean the response from exposed methods. So, you should do it by your own code.
Next (Installation) >


method ILI forecast data dengue error using incidence time case model methods forecasting ARLR used []. ARGO ;():–. lasso naive peak search values forecasts different models value method. real-time sparse use ahead given Comparison Glmnet actual count disease {border-style Kalman data. number parameters prediction px;} series #ffffff;} influenza obtained standard Dengue estimated flu log seasonal RMS available additional autoregressive counts health mean shown Ensemble Using errors measures nowcast ratio terms training vector ./journal.pcbi..tTable Fig Forecasting RMSE challenge comparison. electronic observed season (.) better described method, obtain reduction uses window ./journal.pcbi. ;:–. Biology. CDC’s Computational Information Method Trends component following frequency multiple order records skill term unweighted variable Autoregressive Error Influenza USA. United absolute based bin bins defined exogenous incidences incidences. labeled need original performance process set weeks weighted years Available Further, Likelihood Mean Naive Ratio Supporting compared computationally corresponding efficient from: important model. month parenthesis predict px; representation viral visit, weekly {font-family Absolute Internet MAPE Taiwan, Tropical [], analysis bootstrap central data, displayed estimate estimates font-size four-week historical information lags leading measures. methods. monthly months probabilities procedure queries regularization residuals selection transformation two-week, (ILI) -year BrownsteinJS, Diseases. In: MAE Methods Peak Proceedings Realtime Sciences States. accurate added algorithm cases comparison correlated dengue. diseases. double; effect ensemble epidemics identical measure. methods, models. outperforms quantification realtime results review score variables zero (ARLR) ARGO, Analysis December March Prediction Research Science Table Text). Yang achieves activity approach border-color border-width countries fitting forecasts, forecasts. illness infection infectious influenza-like large matrix measurement minimizing model, multiplicative outbreaks parameter parameters. post-facto predicting proportion quantify query reported represent seasonality short solid; sources study systematic three-week, times unknown values) world {font-style {font-weight (actual—predicted (rows (that ./j.epidem... ./journal.pntd. BMC BrooksLC, CDC Epidemics. Error, Gaussian Holt-Winters ILI. ILI: International KandulaS, Mathematics National Neglected Probabilities Replication Singapore. Statistical Thailand USA: Uncertainty Xt,g Z,t, additive aggregated am, apply appropriate athenahealth average backfill bold case, coefficient compare compute context countries/states: courier; dates deterministic does em; ending equation estimating forecast. general incidence. included indicates internet ith kg, lasso, length lies like limited linear listed log-transformed manner modeling noise noted outbreaks. paper, past performing period prefitting pt;} recent regional regression related required respectively. scale source starting stationary surveillance taken tropical typically underlying unspecified visit week widely x-axis


Gecode::ViewSelTieBreakDynamic< _View >::Choice Class Reference
Choice for tie breakers More...
#include <brancher-tiebreak.hpp>
Public Member Functions | |
| Choice (Space &home, ViewSelVirtualBase< _View > **tb, int n0) | |
| Constructor. | |
| Choice (const Space &home, Archive &e, ViewSelVirtualBase< _View > **tb, int n0) | |
| Constructor. | |
| Choice (const Choice &ce) | |
| Copy constructor. | |
| const Choice & | operator= (const Choice &ce) |
| Assignment operator. | |
| void | commit (Space &home, unsigned int a, ViewSelVirtualBase< _View > **tb) const |
| Perform commit. | |
| size_t | size (void) const |
| Report size occupied. | |
| ~Choice (void) | |
| Destructor. | |
| void | archive (Archive &e) const |
| Archive into e. | |
Public Attributes | |
| int | n |
| Number of choices. | |
| ChoiceVirtualBase ** | c |
| Choices. |
Detailed Description
template<class _View>
class Gecode::ViewSelTieBreakDynamic< _View >::Choice
Choice for tie breakers
Definition at line 212 of file brancher-tiebreak.hpp.
Constructor & Destructor Documentation
| Gecode::ViewSelTieBreakDynamic< View >::Choice::Choice | ( | Space & | home, | |
| ViewSelVirtualBase< _View > ** | tb, | |||
| int | n0 | |||
| ) | [inline] |
Constructor.
Definition at line 457 of file brancher-tiebreak.hpp.
| Gecode::ViewSelTieBreakDynamic< View >::Choice::Choice | ( | const Space & | home, | |
| Archive & | e, | |||
| ViewSelVirtualBase< _View > ** | tb, | |||
| int | n0 | |||
| ) | [inline] |
Constructor.
Definition at line 465 of file brancher-tiebreak.hpp.
| Gecode::ViewSelTieBreakDynamic< View >::Choice::Choice | ( | const Choice & | ce | ) | [inline] |
Copy constructor.
Definition at line 473 of file brancher-tiebreak.hpp.
| Gecode::ViewSelTieBreakDynamic< View >::Choice::~Choice | ( | void | ) | [inline] |
Destructor.
Definition at line 507 of file brancher-tiebreak.hpp.
Member Function Documentation
| const ViewSelTieBreakDynamic< View >::Choice & Gecode::ViewSelTieBreakDynamic< View >::Choice::operator= | ( | const Choice & | ce | ) | [inline] |
Assignment operator.
Definition at line 480 of file brancher-tiebreak.hpp.
| void Gecode::ViewSelTieBreakDynamic< View >::Choice::commit | ( | Space & | home, | |
| unsigned int | a, | |||
| ViewSelVirtualBase< _View > ** | tb | |||
| ) | const [inline] |
Perform commit.
Definition at line 492 of file brancher-tiebreak.hpp.
| size_t Gecode::ViewSelTieBreakDynamic< View >::Choice::size | ( | void | ) | const [inline] |
Report size occupied.
Definition at line 498 of file brancher-tiebreak.hpp.
| void Gecode::ViewSelTieBreakDynamic< View >::Choice::archive | ( | Archive & | e | ) | const [inline] |
Archive into e.
Definition at line 514 of file brancher-tiebreak.hpp.
Member Data Documentation
| int Gecode::ViewSelTieBreakDynamic< _View >::Choice::n |
Number of choices.
Definition at line 215 of file brancher-tiebreak.hpp.
| ChoiceVirtualBase** Gecode::ViewSelTieBreakDynamic< _View >::Choice::c |
Choices.
Definition at line 217 of file brancher-tiebreak.hpp.
The documentation for this class was generated from the following file:
- gecode/kernel/brancher-tiebreak.hpp (Revision: 12001)


Three star hotels aim towards meeting guest expectations and providing pleasant stay. These hotels are often located near major express-ways, airports, business areas, convenient for shopping trips etc. They thereby provide their short term guests with a brief, efficient but comfortable stay.


{% include head.html %}
{% include navigation.html %}
Contact
{% include footer.html %} {% include js.html %}