mirror of https://gitee.com/bigwinds/arangodb
fix errors pointed out by @pluma
This commit is contained in:
parent
000797eba7
commit
46aeb0f54d
|
@ -44,13 +44,14 @@ It is also possible to supply parameters to the query:
|
||||||
```javascript
|
```javascript
|
||||||
// in the repository
|
// in the repository
|
||||||
getPendingItemById: Foxx.createQuery(
|
getPendingItemById: Foxx.createQuery(
|
||||||
'FOR todo IN my_todos FILTER todo.completed == false FILTER todo._key == @key RETURN todo'
|
'FOR todo IN my_todos FILTER todo.completed == false FILTER todo._key == @id RETURN todo'
|
||||||
)
|
)
|
||||||
|
|
||||||
// in the controller
|
// in the controller
|
||||||
ctrl.get("/:id", function(req, res) {
|
ctrl.get("/:id", function(req, res) {
|
||||||
var id = req.params("id");
|
var id = req.params("id");
|
||||||
res.json(todosRepository.getPendingItemById(id));
|
var rv = todosRepository.getPendingItemById({ id: id });
|
||||||
|
res.json(rv);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -59,7 +60,7 @@ The list of results can also be transformed before returning it from the reposit
|
||||||
```javascript
|
```javascript
|
||||||
// in the repository
|
// in the repository
|
||||||
getPendingItemById: Foxx.createQuery({
|
getPendingItemById: Foxx.createQuery({
|
||||||
query: 'FOR todo IN my_todos FILTER todo.completed == false FILTER todo._key == @key RETURN todo',
|
query: 'FOR todo IN my_todos FILTER todo.completed == false FILTER todo._key == @id RETURN todo',
|
||||||
transform: function(results, args) {
|
transform: function(results, args) {
|
||||||
for (var i = 0; i < results.length; i++) {
|
for (var i = 0; i < results.length; i++) {
|
||||||
results[i].extraProperty = args.extra;
|
results[i].extraProperty = args.extra;
|
||||||
|
@ -72,8 +73,8 @@ ctrl.get("/:id", function(req, res) {
|
||||||
var id = req.params("id");
|
var id = req.params("id");
|
||||||
var extra = req.params("extra");
|
var extra = req.params("extra");
|
||||||
var rv = todosRepository.getPendingItemById(
|
var rv = todosRepository.getPendingItemById(
|
||||||
{ id: id },
|
{ id: id },
|
||||||
{ extra: extra }
|
{ extra: extra }
|
||||||
);
|
);
|
||||||
res.json(rv);
|
res.json(rv);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue