-
-
Notifications
You must be signed in to change notification settings - Fork 739
Description
Expected Behavior
When I get normally without embedded
the total in HATEOAS return correct total belong to this code
https://github.com/pyeve/eve/tree/c4e894aeaadd982c6449329b00fcb050e6c70152/eve/io/mongo/mongo.py#L274
"_links": {
"parent": {
"href": "/",
"title": "home"
},
"self": {
"href": "tickets?max_results=5",
"title": "tickets"
}
},
"_meta": {
"max_results": 5,
"page": 1,
"total": 5
}
I want the same thing with embedded={"user": 1}
Actual Behavior
But when embedded
https://github.com/pyeve/eve/tree/c4e894aeaadd982c6449329b00fcb050e6c70152/eve/methods/common.py#L896
will update __last_target
https://github.com/pyeve/eve/tree/c4e894aeaadd982c6449329b00fcb050e6c70152/eve/io/mongo/mongo.py#L261
then the return of total https://github.com/pyeve/eve/tree/c4e894aeaadd982c6449329b00fcb050e6c70152/eve/io/mongo/mongo.py#L274
will be wrong
"_links": {
"parent": {
"href": "/",
"title": "home"
},
"self": {
"href": "tickets?max_results=5",
"title": "tickets"
}
},
"_meta": {
"max_results": 5,
"page": 1,
"total": 1
}
the spec will be like this {'$or': [{'_id': ObjectId('5cc02d98bf42f8740738916d')}]} after cursor.next()
And I tried to fix by using cursor.count() instead app.data.last_documents_count, but I'm not sure that going to work without a test.
Environment
- Python version: 3.6.7
- Eve version: 0.9