Update remote method example
This commit is contained in:
parent
ba5814aeff
commit
6695a338d3
11
docs/api.md
11
docs/api.md
|
@ -511,12 +511,13 @@ Expose a remote method.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
Product.stats = function(fn) {
|
Product.stats = function(fn) {
|
||||||
var calc = require('./stats');
|
var statsResult = {
|
||||||
|
totalPurchased: 123456
|
||||||
|
};
|
||||||
|
var err = null;
|
||||||
|
|
||||||
Product.find(function(err, products) {
|
// callback with an error and the result
|
||||||
var productStats = calc(products);
|
fn(err, statsResult);
|
||||||
fn(null, productStats);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loopback.remoteMethod(
|
loopback.remoteMethod(
|
||||||
|
|
Loading…
Reference in New Issue