首页 > 解决方案 > How to filter in python eve by object id string without schema

问题描述

I am using python eve to build a data storage service. All my collections are schemaless, so I've set ALLOW_UNKNOWN setting to True. Everything works fine except with fields referencing another ones. I'm trying to request a collection filtering by an object id string and I am always getting an empty list.

For example, I have apps and task collections set in DOMAIN setting.

The sequence of request I do is as follow:

POST '/apps':

{
    "name": "test"
}

GET '/apps':

{
    "_items": [
        {
            "_id": "5afb45872fb8d57c7d93d8fa",
            "name": "Test app",
            "_updated": "Tue, 15 May 2018 20:39:35 GMT",
            "_created": "Tue, 15 May 2018 20:39:35 GMT"
        }
    ],
    "_meta": {
        "page": 1,
        "max_results": 25,
        "total": 1
    }
}

POST '/tasks':

{
    "title": "Check log files",
    "app_id": "5afb45872fb8d57c7d93d8fa"
}

GET '/tasks':

{
    "_items": [
        {
            "_id": "5afb4bcd2fb8d57c7d93d912",
            "title": "Check log files",
            "app_id": "5afb45872fb8d57c7d93d8fa",
            "_updated": "Tue, 15 May 2018 21:06:21 GMT",
            "_created": "Tue, 15 May 2018 21:06:21 GMT"
        }
    ],
    "_meta": {
        "page": 1,
        "max_results": 25,
        "total": 1
    }
}

GET '/tasks/?where={"app_id": "5afb45872fb8d57c7d93d8fa"}:

{
    "_items": [],
    "_meta": {
        "page": 1,
        "max_results": 25,
        "total": 0
    }
}

My question are:

Looking at docs I've found the query_objectid_as_string setting, however document endpoints return 404 error.

GET /tasks/5afb4bcd2fb8d57c7d93d912 -> Not found

标签: pythoneve

解决方案


推荐阅读