curl - 使用 HTTP 请求 CouchDB 3.0.0 检索文档
问题描述
我是 CouchDB 的初学者,在网上我读到可以使用 HTTP 请求运行 Mango 查询。我已经很努力了,但我无法处理这样的查询。
这是命令
C:\>curl -X POST http://root:root@127.0.0.1:5984/movielens/_find -d @query.json
{"error":"bad_content_type","reason":"Content-Type must be application/json"}
这是 json 文件的主体:
{"selector": { "Genres": {"$elemMatch": {"$eq": "Drama"}}}}
据我了解,我不知道我错在哪里。那么,我该如何运行这个查询呢?
解决方案
您需要将Content-Type
标题中的 设置为application/json
。
尝试这个:
curl -X POST http://root:root@127.0.0.1:5984/movielens/_find --header 'Content-Type: application/json' -d @query.json
推荐阅读
- html - 如何在左侧逐行设置所有复选框及其标签?
- python - 将新创建的列添加在一起
- java - 点亮(空).cast(“地图
") 不被接受。如何转换为具有价值对象的地图? - php - 无法将 Angular 中的数据插入到 Laravel API
- javascript - 按钮单击需要在移动设备上双击或长按
- reactjs - React Router Dom-在 React 中处理 404 路由(嵌套路由器)
- concurrency - ConcurrentHashMap中如何同时对同一段进行两次读取操作?
- visual-studio - 如何:使用 CMake 构建系统在 Visual Studio 中附加包含 C++ 项目的路径?
- node.js - 如果我使用循环(for)发送带有令牌数据的推送而不考虑人数,是否有任何问题?
- mongodb - Javascript - 切换 xp 系统(mongodb 和 discord.js 与 discord-xp api)