python - 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:
- How can I post an ObjectId field without a defined schema?
- How can I retrieve tasks filtering by
app_id
?
Looking at docs I've found the query_objectid_as_string
setting, however document endpoints return 404 error.
GET /tasks/5afb4bcd2fb8d57c7d93d912 -> Not found
解决方案
推荐阅读
- javascript - 如何将字符串的 java ArrayList 传递给 JavaScript
- python - 获取 Python Django Rest 框架代码的错误
- c - int *ptr= 5; 与 int *ptr= 变量地址不同?
- javascript - 回调必须是节点中的函数
- java - 将上下文从服务类传递到另一个服务类
- mysql - 用计算每个父母的每个关系孩子来对 findall 进行续集
- spring-boot - 如何在junit 5单元测试中模拟@Autowired的对象?
- wix - 是否可以为 dotnet core 3.1 创建 wix c# 自定义操作项目?
- python - 避免矩阵的全奇异值分解
- elasticsearch-painless - 过滤器查询中的 null_pointer_exception 与存储的脚本匹配